Question by
FourtifiedGaming · May 10, 2016 at 04:12 AM ·
movement scriptplayer movementisometric
Player To Mouse movement in 3d isometric game
Hey guys,
I am making a 3d isometric game and I am trying to get my player to follow turn and face the mouse when the mouse moves. I have this code so far, and it works, but I need it to be tighter. As of now, the character doesnt face the mouse head on and becomes hard to control. How can I tighten this up?
Heres the code
Vector3 turnDir = new Vector3 (Input.GetAxisRaw ("Mouse X"),0, Input.GetAxisRaw ("Mouse Y"));
if (turnDir != Vector3.zero)
{
playerToMouse = (transform.position + turnDir) - transform.position;
playerToMouse.y = 0f;
Quaternion newRotation = Quaternion.LookRotation (playerToMouse);
playerRigidbody.MoveRotation (newRotation);
Comment
Your answer
Follow this Question
Related Questions
While moving right, gameobject reacts to left-button, but not the other way around. 1 Answer
Controller / movement script rotate while moving HELP 0 Answers
Player only moves when the key is pressed, not when it's held. 0 Answers
Move Player along normal of floor? 1 Answer
MoveTowards not moving accurately. Getting stuck on target. 2 Answers