I have this script:
var lookTarget : Vector3;
function Update() {
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit)){
lookTarget = hit.point;
}
transform.LookAt(lookTarget);
}
I have it attached to my player but when I move the cursor closer to my player it will flip around. How do I fix this?