WowieGameJam/Assets/Scripts/Aim.cs
Gerard Gascón a8c6025cd3 init
2025-04-24 14:07:24 +02:00

17 lines
483 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Aim : MonoBehaviour{
public Vector3 difference;
// Update is called once per frame
void Update(){
difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
difference.Normalize();
float rotZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, 0f, rotZ);
}
}