2020-12-03 19:38:25 +01:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class GunRotation : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private void FixedUpdate()
|
|
|
|
|
{
|
|
|
|
|
Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
|
|
|
|
|
difference.Normalize();
|
2020-12-20 13:37:48 +01:00
|
|
|
|
float rotation = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
|
|
|
|
|
transform.rotation = Quaternion.Euler(0f, 0f, rotation);
|
|
|
|
|
|
2020-12-03 19:38:25 +01:00
|
|
|
|
}
|
2020-12-20 13:37:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-12-03 19:38:25 +01:00
|
|
|
|
}
|