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);
}
}