- Home /
GameObject moving forward depending on its orientation?
Hello everyone.
I'd like to know how I could make a gameObject moving forward its orientation. In fact, I'd like to invert the quaternion from time to time. So if the movement depends on the orientation I'll only have to play with Quarternion to change the movement direction instead of playing with x,y and z.
Thanks in advance
Answer by karljj1 · Nov 27, 2013 at 09:47 AM
Sounds like you want transform.forward.
http://docs.unity3d.com/Documentation/ScriptReference/Transform-forward.html
Answer by Baalhug · Nov 27, 2013 at 10:49 AM
Vectors are the most usefull tool for this kind of trouble. And unity use them in a friendly way, so you can copy a character controller script and modify it. The default char controller you can find in standard assets moves your char using absolute coordinates, i mean when you press "left arrow" on your keyboard it will move towards left of your screen. To modify this you must change to rotation when pressing left and right arrow keys and to move forward when you press up arrow, for instance. To do this you must use the Vector3 your char has in every moment, for rotation and for advancing, instead of using absolute coordinates (screen).
Your answer
![](https://koobas.hobune.stream/wayback/20220613122919im_/https://answers.unity.com/themes/thub/images/avi.jpg)