# Problem switching from axis Z to axis Y

Hi, I have a problem and I would really like some help.

I’ve started using Unity recently, and I’ve been using a tutorial as a basis to start doing a game that I have in mind (this tutorial: http://unity3d.com/learn/tutorials/projects/space-shooter). I’ve been doing great, and I’ve even modify some things in order to start making it more like the game that I have in mind. But along those changes, I’ve switched from using the X and Z axis (like the tutorial does) to use the X and Y axis.

The thing is, everything is in place, but for some reason the movement is failing. The movement script for the XY versión is this:

``````public float acceleration=1;
public float topVelocity=0.5f;
public float speed = 10;
public float tilt=4;
public Boundary boundary;

public string xAxis;
public string yAxis;

void FixedUpdate(){
float moveHorizontal = Input.GetAxis (xAxis);
float moveVertical = Input.GetAxis (yAxis);
float xAcceleration=moveHorizontal*acceleration;
float yAcceleration=moveVertical*acceleration;
if(xAcceleration!=0 || yAcceleration!=0){
Debug.Log("Move Horizontal: "+moveHorizontal+" Move Vertical: "+moveVertical);
Debug.Log("Acc X: "+xAcceleration+" Acc Y: "+yAcceleration);
}

checkMaxSpeed();
checkBoundary();
//rigidbody.rotation = Quaternion.Euler (0.0f,0.0f,rigidbody.velocity.x*-tilt);
}

void checkMaxSpeed(){
rigidbody.velocity=new Vector3(
Mathf.Clamp(rigidbody.velocity.x,-topVelocity,topVelocity),
Mathf.Clamp(rigidbody.velocity.y,-topVelocity,topVelocity),
0.0f
);
}

void checkBoundary(){
rigidbody.position=new Vector3(
Mathf.Clamp(rigidbody.position.x,boundary.xMin,boundary.xMax),
Mathf.Clamp(rigidbody.position.y,boundary.yMin,boundary.yMax),
0.0f
);

if(rigidbody.position.x==this.boundary.xMax || rigidbody.position.x==this.boundary.xMin)
{rigidbody.velocity=new Vector3(0.0f,rigidbody.velocity.y,0.0f);}

if(rigidbody.position.y==this.boundary.yMax || rigidbody.position.y==this.boundary.yMin)
{rigidbody.velocity=new Vector3(rigidbody.velocity.x,0.0f,0.0f);}
}
``````

And the one for the XZ version is like this:

``````public float acceleration=1;
public float topVelocity=0.5f;
public float speed = 10;
public float tilt=4;
public Boundary boundary;

public string xAxis;
public string yAxis;

void FixedUpdate(){
float moveHorizontal = Input.GetAxis (xAxis);
float moveVertical = Input.GetAxis (yAxis);
float xAcceleration=moveHorizontal*acceleration;
float zAcceleration=moveVertical*acceleration;

checkMaxSpeed();
checkBoundary();
//rigidbody.rotation = Quaternion.Euler (0.0f,0.0f,rigidbody.velocity.x*-tilt);
}

void checkMaxSpeed(){
rigidbody.velocity=new Vector3(
Mathf.Clamp(rigidbody.velocity.x,-topVelocity,topVelocity),
0.0f,
Mathf.Clamp(rigidbody.velocity.z,-topVelocity,topVelocity)
);
}

void checkBoundary(){
rigidbody.position=new Vector3(
Mathf.Clamp(rigidbody.position.x,boundary.xMin,boundary.xMax),
0.0f,
Mathf.Clamp(rigidbody.position.z,boundary.zMin,boundary.zMax)
);
if(rigidbody.position.x==this.boundary.xMax || rigidbody.position.x==this.boundary.xMin)
{rigidbody.velocity=new Vector3(0.0f,0.0f,rigidbody.velocity.z);}
if(rigidbody.position.z==this.boundary.zMax || rigidbody.position.z==this.boundary.zMin)
{rigidbody.velocity=new Vector3(rigidbody.velocity.x,0.0f,0.0f);}
}
``````

As far as I can see, I switched all the parameters from Z to Y, but when I run it, the ship doesn’t move. Has anyone encountered something similar before? I could really use a hand.

Also, if you’re interested in looking at the whole shebang, here are both versions:

Sorry if it’s too much to ask, but I could really use some help here.