Simple Movement Script - Learning

Hey folks, Im now at the point where Im trying to learn the scripting. I’ve been working at this for a couple of hours now I would appreciate the help.

In the scene its a simple object, no animations. My goal is to get it to move forward on w, backwards on s, rotate left on a and rotate right on d.

Im having problems with the following: Seems he will go right, but not the rest of the directions. Thank you!

Below is my script.

var speed : int = 10.0;
var turnSpeed : int = 10;
var rotationSpeed : int = 100.0;

function Update () 
{
if (Input.GetButton("Horizontal")) {
rigidbody.velocity = transform.forward * speed;
}
	else{
		if(Input.GetButton("Horizontal")){
rigidbody.velocity = -transform.forward * speed;		
	}
	else{
	rigidbody.velocity = Vector3.zero;
	}
	if (Input.GetButton("Vertical")){
transform.Rotate(0,-turnSpeed * Time.deltaTime,0);
	
	}
	if(Input.GetButton("Vertical")){
	transform.Rotate(0,turnSpeed * Time.deltaTime,0);
	}
	}
	}

Ok silly me, should have done a bit more research this is covered in the basic learning Unity script document. There is a link to it at the top of the thread in the sticky.

:sweat_smile: