How do I leave an X and Y axis coordinate as itself ?

var speed;
function Start(){
speed = Random.Range(50,80);
}
function Update(){
this.transform.Translate(Vector3(speed,0,0) * Time.deltaTime);
this.transform.position = Vector3(0,0,6);

}

Yo

Um I’ve got a game object that’s meant to move in a straight line . But because of the way its rotated it always goes slightly left . I’ve added in a line to keep it on it’s Z axis where it’s meant to be (on Z6) but how do I make it so the X and Y axis stay as they . The way it is now it stays on the right Z axis but it’s frozen in 0 , 0 ,6 . I want the X and Y to keep Moving along , instead of being locked to a position .

Sorry if it doeesn’t make sense its hard to explain

All Help appreciated

Thanks SS

If what you want is to keep your object from moving on the z axis, Try Changing

this.transform.position = Vector3(0,0,6);

For this

this.transform.position = Vector3(transform.position.x,transform.position.y,6);