I am working on a basic left/right/jump movement script in Unity. At first I used transform.translate to move the object around, but when the problem of going through colliders occured I started using a rigidbody, and the velocity function. But the problem with this is my object starts rotating uncontrollably from this. How can i make this script work?
function Update () {
if (Input.GetKeyDown ("space"))
rigidbody.velocity = Vector3.up;;
if (Input.GetKey ("left"))
rigidbody.velocity = Vector3.left ;;
if (Input.GetKey ("right"))
rigidbody.velocity = Vector3.right;;
}
I have looked all over for an answer to this, and although i know it is simple and probably easy to find I just can’t figure it out.