Player Rotation Around Mouse
Hey guys, i'm having some problems with my player rotation around the mouse only using horizontal motion. I would like the player to always be pointing towards the mouse no matter the position on the screen although, the player is only rotation to the mouse according to the coordinates on the screen and not in the game world.
The player is also doing weird things like moving on its own. I have been working on this problem for days now and i just can't seem to crack it. Oh also, just in case this is relevant, the game is isometric. I thought that maybe this would be the cause but i just can't see at to why it would be.
Here is the code i am using:
void Update () {
Vector3 lookDirection = (new Vector3(Input.mousePosition.x, 0, Input.mousePosition.z));
lookDirection.y = 0;
Debug.Log(lookDirection);
transform.LookAt(Camera.main.ScreenToWorldPoint(lookDirection));
}
Thank you very much in advance!
Your answer
Follow this Question
Related Questions
How do I rotate my object back to the world's up direction whilst keeping it's forward direction? 0 Answers
How can I make my GameObject rotate this way? 0 Answers
Rotate Object Axis On Swipe Cam Rotation - Android 1 Answer
How can I incorporate a Rotation Towards the Mouse Position into this Script? I Tried. 0 Answers
Rotate camera upward. 0 Answers