I use click to move, but don't want my player to rotate... How to fix this rotation?
I'm making my first game in unity. What I trying to achieve is letting a player move by clicking somewhere in the room. (this works!). But to look around, I use a drag screen to look script (also works).
The only problem I have at this moment is: my player is rotating when I'm clicking somewhere in the room to move the player. How can I stop this rotation?
This is my click to move script, I think I have to normalize something but don't know how...
public LayerMask whatCanBeClickedOn; private NavMeshAgent myAgent; private void Start() { myAgent = GetComponent (); } private void Update() { if (Input.GetMouseButtonDown (0)) { Ray myRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(myRay, out hitInfo, 100, whatCanBeClickedOn)) { myAgent.SetDestination (hitInfo.point); }
}
}