You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
658 B
28 lines
658 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace CartoonCoffeeFireVFX
|
|
{
|
|
public class DemoAimer : MonoBehaviour
|
|
{
|
|
Transform arm;
|
|
|
|
void Start()
|
|
{
|
|
arm = transform.Find("Arm");
|
|
}
|
|
|
|
void LateUpdate()
|
|
{
|
|
HandleAiming();
|
|
}
|
|
|
|
void HandleAiming()
|
|
{
|
|
Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
|
mousePosition.z = arm.position.z;
|
|
arm.eulerAngles = new Vector3(0, 0, Vector2.SignedAngle(Vector2.right, mousePosition - transform.position));
|
|
}
|
|
}
|
|
}
|