Rotating a GameObject

Hello all,

I’m trying to rotate my gameobject when I press a key, similar to what happens when you move. I’m using this script to move and would like to be able to rotate to simulate movement by rotating.

Any help would be greatly appriciated by me and my bloodshot eyes :smile:

function Update () { 
   rigidbody.AddForce(Input.GetAxis("Horizontal"), 0,
   Input.GetAxis("Vertical"));
   
}

There are a few things to note:

Something like this:

function Update () { 
   transform.Rotate(0.0, Input.GetAxis("Horizontal"), 0.0);
}

function FixedUpdate () {

   rigidbody.AddForce(Input.GetAxis("Horizontal"), 0,
   Input.GetAxis("Vertical"));
   
}

That’s a simple example of how you might want to go about it. Perhaps you want to adjust the actual rate of rotation, but I’ll leave that as an exercise for you. :slight_smile:

Thanks for the help HiggyB, worked a treat. At this stage theres alot of trial and error but it’s all worth it in the end :smile: