Hi All,
I’m trying out some of my first ever scripting by creating a simple scene where I am trying to move a cylinder along the X-Axis. I have written the following but whenever I attempt to move the object via the right or left arrow keys instead of moving directly along the X-Axis my object appears to also rotate slightly around the Z-axis.
Can anyone give me a pointer or advise what it is I’m doing wrong? Thanks, code listing of my script which is attached to a cylinder with a rigidbody that is placed on top of a plane:
var speed = 0.5;
function Update () {
var horiz : float = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
transform.Translate(horiz,0,0);
}