- Home /
WASD Movement with Mouse position dictating which way the character is facing
How would I go about doing this? I have basic WASD Movement, a locked top down/almost isometric camera (though the camera is not following the character). I just cannot for the life of me figure out how to get my character to turn whichever direction the mouse is facing.
I've been using C# so far, though admittedly have no idea what the hell im doing. Been learning the hard way, whenever I don't know what something is I look it up and so far have got a title screen working and now am stuck on character controls.
Will try to help answer any questions you may have, still pretty new at unity. This is my first real project.
@liamcary 's answer is probably what you are looking for, but I quite visualize your problem. In particular I cannot figure out how the WASD key movement interacts with the mouse "position." I assume when you say "turn whichever direction the mouse is facing," you are talking about projecting the mouse position down to character eye level. Oh, and is the plane even or some sort of terrain?
Answer by liamcary · Feb 28, 2013 at 05:21 AM
Are you aiming for something like Beat Hazard but in an isometric world? You could do that by raycasting into the screen from the mouse position and setting the player's transform.LookAt() to be the position where the raycast collides with the ground.
I'd recommend you look at using Camera.ScreenPointToray, a Layer Mask to ensure the raycast hits the ground, and Transform.LookAt to actually set the player to look towards the point that the raycast hit.