- Home /
Vertical & horizontal movement world axis (top view)
Does anyone know how to script horizontal and vertical movement only in the world axis so my player can turn freely and their local direction doesnt effect the way forward left right is, my game is top view.
Thankyou
Answer by brandon1 · Feb 02, 2011 at 02:25 PM
how to move in world axis in c#
transform.Translate(new Vector3(
Input.GetAxis("Horizontal")*speed*Time.deltaTime,
0.0f,
Input.GetAxis("Vertical")*speed*Time.deltaTime,
Space.World));
if you don't specify Space.World it assumes you want to move on the transforms local axis.
Note: You said top view so I assumed you wanted to move on x and z axis, if you want to move on x and y, just switch the 2nd and 3rd arguments on the Translate function I provided.
thanks but ive been trying for a long time to convert this script to WASD controls im pretty confused sorry is there anychance u could help me with that thankyou
Your answer
Follow this Question
Related Questions
Moving Camera with WASD 6 Answers
wasd movement rigidbody no bouncing 0 Answers
Top down 2d movement without being affected by rotation 2 Answers
Whats the best way to move a 2d rigidbody? 2 Answers
Enemy Movement Help 3 Answers