I am pushing a cube around on a plane using AddRelativeForce. Expectedly, the cube does not change it's orientation when doing this. How can I orient the cube so that the positive Z is always facing the direction that the object is moving. In other words, if I created a direction bt taking the position of the last frame and the position of the current frame, how would I point the Z of the cube in that direction?
var xdirection : float;
var ydirection : float;
function Update(){
//This in the user calibrated acceleration input code
xdirection = Input.GetAxis ("Vertical") ;
ydirection = Input.GetAxis ("Horizontal") ;
}
function FixedUpdate () {
var relativeForce = Vector3(ydirection, 0, xdirection);
rigidbody.AddRelativeForce (relativeForce);
}