I'm working on a top down controller for my character. Right now, it rotates towards where the mouse is on the screen, and when you press 'W', or UP it will move forward in the direction of the mouse. 'S' or DOWN, will move away and so on.
This works fine, but I also want an option so I can change the movement to world directions, what I mean by that, is no matter what rotation the character is at, 'W' or UP will always move Up/North/+Z, and the same with all the other directions. For some reason, I really cant seem to get my head around this?
Below is my script for moving the character in local position, with rotation of the mouse:
And then in the world position, I'm not making any progress, my character 'tries' to move, but seems like hes stuck, and then just bounces back to his original position?
asked May 21 '12 at 05:16 PM
It's quite simple. You just use position.x or position.z.
This makes the gameobject move along the worlds x-axis and it does not depend on its angle.
It think for example Vector3(2,0,0) also works just fine.
Hope this helps.
answered May 22 '12 at 03:53 PM