I’m trying to make a simple top down shooter game for my first game in unity, I am by no means good at c#, I’m trying to get the player to face the direction of the mouse so that the player can aim at the enemies, however with my current code:
Vector3 input = Input.mousePosition;
Vector3 mousePosition = Camera.main.ScreenToWorldPoint(new Vector3(input.x, input.y, Camera.main.transform.position.y));
transform.LookAt(new Vector3(mousePosition.x, transform.position.y, mousePosition.z));
In the update method, but for some reason it faces the mouse in some positions, but doesn’t in overs. here is a video at what is happening https://youtu.be/--XU7_nRSOs
.
Thank you in advance. (this is my first time asking something on here)
I Am Me is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.