public float LookAngle() { Vector3 targetPos; if (followControl) { targetPos = mousePosition.GetMousePos(); } else { targetPos = target.position; } aimDir = (targetPos - transform.position).normalized; return(Mathf.Atan2(aimDir.y, aimDir.x) * Mathf.Rad2Deg); }
// Update is called once per frame void Update() { transform.eulerAngles = new Vector3(0, 0, LookAngle(mousePosition.GetMousePos())); }