Pracownia-Programowania-Pro.../Assets/Scripts/GunRotation.cs
Polarjad 97b7b765fd Added enemy AI
Added wip sprites for map, changed shooting, added 2 different enemy AI, added health system
2021-01-13 18:58:14 +01:00

20 lines
453 B
C#

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