I am new to Unity but still a very experienced Python coder and Maya Animator so forgive me if I ask stupid questions in UnityScript. :)
I am trying to develop a controller for moving the character around. Think of the set-up as controlling a radio controlled car and watching it from above, looking strait down at it. In the game the player moves the character along the ground along x and z axis. The camera, for now, is simply moved up 20 units and looking strait down at the character.
I can move the character around with a simple control script like the following:
What I can't figure out is how do I steer the character in the direction of the motion? I've seen a couple of answers for something similar that I have tried but they all have one undesirable result, they return the character back to facing at it's origin (0 degrees north) when the motion stops. The problem I am running into is when the player stops, the car shouldn't magically return to facing up the Z-Axis, it should stay facing in the last direction it was moving in.
Also, I am applying the script to a generic GameObject with the geometry for the car parented underneath it. Should I be using a CharacterController instead?
I hope this all makes sense and any help you can spare would be greatly appreciated.
asked Aug 05 '10 at 05:48 AM
You're better off using "var speed = 10.0" or "var speed : float = 10", because otherwise speed is limited to integers (it's also a teensy bit slower, since the int has to be converted to a float every time it's used).
I changed the movement so it's setting the transform.position directly instead of using Translate. Since Translate is relative, the movement wouldn't work the same anymore when you change the heading.
answered Aug 05 '10 at 06:59 AM