# Cube bounces back with rigidbody and script in Unity

I have Unity 4.6.1 and I added a cube with a moving script and a rigidbody. The script is:

#pragma strict

var speed : float = 10.0;

function Update () {

// Is the user pressing left or right (or "A" & "D") on the keyboard
var horMovement = Input.GetAxis("Horizontal");
// Is the user Pressing up or down (or "W" & "S") on te keyboard
var forwardMovement = Input.GetAxis("Vertical");

if (horMovement) {
transform.Translate(transform.right * horMovement * Time.deltaTime * speed);
}

if (forwardMovement) {
transform.Translate(transform.forward * forwardMovement * Time.deltaTime * speed);
}
}


And the rigidbody freezes position Y and freezes rotation X, Y, and Z. How do I stop it from bouncing back?

• By bouncing you mean the slight movement backwards? – Vadim Tatarnikov Aug 5 '15 at 5:42
• @VadimTatarnikov Yes I do mean that. – kprovost7314 Aug 5 '15 at 20:19