left and right 2d walk

Hi I am newer to scripting and I have a question about 2d movement. Originally this script I got from a tornado twins youtube video. I edited it so it would not rotate a character.

#pragma strict

function Start () {


var speed : float = 3;

var rotateSpeed : float = 3;

function Update() { var controller : CharacterController = GetComponent( CharacterController );

var forward = transform.TransformDirection( Vector3.forward );

var curSpeed = speed * Input.GetAxis( “Vertical” );

controller.SimpleMove( forward * curSpeed );


@script RequireComponent( CharacterController );

The only problem is that I walk with up and down instead of left and right. Is there a solution?

You need to get your input from the “Horizontal” axis instead of the “Vertical” one.

Vertical = up/down

Horizontal = left/right (like the horizon)