Hey guys,
I’ve got a rolling ball with an EmptyObject attached to it. On this EmptyObject I have a box which is attached to the EmptyObject by a spring. This all works well although I have now tried to associate a script with the box which when the ball moves, the face of the box turns to move in that direction as well.
Here is the script I am using for this:
#pragma strict
function Start () {
}
function Update () {
transform.forward = Vector3.Normalize(new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical")));
}
This turns the box perfectly well in the direction the ball is moving, but when you release a key, the box goes back to its default position (I guess this is its ‘z’ position). Is there a way to keep the direction that the box object is turned in and stay there until another key is pressed?
Thanks in advance.
R
Just to add to this, I have noticed that when the object turns, say from 'A' key to 'D' key it jumps around to the direction, rather than turning 180. I'd ideally like it to smooth rotate into the direction the ball is moving. Thanks
– RichCoggin