using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class AutoAim : MonoBehaviour { public GameObject enemy; public float lookSpeed = 200; public GameObject head; public Camera cam; void Start() { } // Update is called once per frame void Update() { if (enemy) { Vector3 direction = enemy.transform.position - cam.transform.position; Quaternion targetRotation = Quaternion.LookRotation(direction); Quaternion lookAt = Quaternion.RotateTowards(cam.transform.rotation, targetRotation, Time.deltaTime * lookSpeed); cam.transform.rotation = lookAt; } } }