Here I have a 2D top down game. Currently the camera is set on the player position. The player constantly points to mouse position.
I want to modify this setup having the camera to be set slightly forward in the player.transform.up
direction but when I try it as the mouse gets closer to the character it starts looping because as the mouse approache, the camera turns but also change the mouse position so the camera needs to turn again, and so on.
this is the camera update
transform.position = new Vector3 (player.transform.position.x, player.transform.position.y, -10) + player.transform.up * camDistance;
and this is how the mouse position gets updated
mousePos = Camera.main.ScreenToWorldPoint (new Vector3(Input.mousePosition.x, Input.mousePosition.y, -5)) - transform.position;
any clue?
the camera turns but also change the mouse position
how does the camera turn, affect your mouse location ? i didn't get what is happening exactly \$\endgroup\$