Auto running in 2D

Hi I am trying to get a 2D game running and i have a 3D character modell which i can controll on the X axis. Now I was wondering how can I get my Char to walk automatically constant from the left to the right endlessly (like Robo Unicorn, Techno Kitten etc.)

var playerSpeed : int;

var xOff : float;

var yOff : float;

var walking = false;

function Update () {

// amount to move Player

xOff += (playerSpeed * Input.GetAxis(“Horizontal”)) * Time.deltaTime;

this.transform.position.x = Camera.main.transform.position.x + xOff;

//play Animation

if(Mathf.Abs(Input.GetAxis(“Horizontal”)) > 0.2)

    animation.CrossFade("walk");

else

    animation.CrossFade("idle");

}

function OnTriggerEnter (collisionInfo : Collider) {

if (collisionInfo.gameObject.tag == “Enviroment”){

Destroy(gameObject);

}

}

You can add this code (in which you have to set speed properly to your purposes):

var speed = 2.0;

function Update () {
   var x_auto = Time.deltaTime*speed;
   transform.Translate(x_auto,0,0);
}

For simplicity, i’ve figured this as a different Update function (so, I imagine it inside another script, and not the one of yours), and I omitted the Animation instructions.