# Plane won't move with transform.Translate

Code:

    void Update () {
transform.position += transform.forward * 0.1f;
float temp = Input.acceleration.x;
float z = Input.acceleration.z;
float x = Input.acceleration.x;
float y = Input.acceleration.y;
//Debug.Log (temp);
transform.Translate (0,-y * speed * Time.deltaTime, 0);
transform.Translate (-x * speed * Time.deltaTime,0, 0);
transform.Rotate (0,0,-temp * speed);
}


The rotation seems to work fine, but when I tilt the phone, nothing happens to the plane's position in space. What's wrong?

EDIT: I know there are some silly aspects to the code, just bear with me while I debug it.

I also think it has something to do with the plane's constant velocity in the top of the code, but I don't know how to make it move with a constant speed forward but still let the user change the Z-Y coordinates via tilting.

• I have verified that your code works, but based off your other questions, I am still sure you have a problem. Unfortunately, its not here. Adding that code to a cube in an empty project, the cube moves, although sporadically. Perhaps your speed value is so low that movement is simply unnoticeable? I might suggest also adding a Debug.Log(Input.acceleration.x to your update, just to confirm your phones accelerometer is not in fact faulty (always good to cross off the low-chance-but-possible stuff, as eventually it will bite you) Aug 18, 2016 at 15:30
• As for your translate code, you can make it easier to read (for you and others) by working out the last translation vector, and applying it in one go. Something like float x = yInput * speed * deltaTime; floaty = xInput * speed * deltaTime; transform.Translate(x, y, z). Aug 18, 2016 at 15:32
• Try and comment out as much code as you can, in your entire class, while still applying input. If you work out the problem, great. Post what lines you commented out to stop the problem. If not, post the entire class. Im not sure how others feel about "code dumps", but Im happy to look through it sometime tomorrow(today) and clean it up/work it out for you Aug 18, 2016 at 15:34