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:
var speed = 10;
function Update () {
//print("UPDATING");
var horizontalInput = Input.GetAxis("Horizontal");
var verticalInput = Input.GetAxis("Vertical");
var xPos = horizontalInput * Time.deltaTime * speed;
var zPos = verticalInput * Time.deltaTime * speed;
transform.Translate( xPos, 0, zPos );
}
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.
Thanks, Grant