Search Unity

Accelerometer not working over network

Discussion in 'Android' started by nitishk, Apr 15, 2013.

  1. nitishk

    nitishk

    Joined:
    Mar 23, 2013
    Posts:
    10
    I have code which allows the player to move an object by tilting their phone. For testing purposes I used arrow keys on desktop and it works fine over the network but when I switch platform to Android it stops working. Here is the code.

    This is the desktop code:
    Code (csharp):
    1. velocity.x = Input.GetAxis("Horizontal");
    This is the android code
    Code (csharp):
    1. velocity.x = -Input.acceleration.y;
    This is the ONLY line that is changing and the object just keeps going to the right on my phone.
     
  2. nitishk

    nitishk

    Joined:
    Mar 23, 2013
    Posts:
    10
    Okay so I found out what the problem is, I will explain what I did in case some one else faces the same problem.

    I was using Unity Remote to test my accelerometer code with the game running in the editor. When I push the app onto the phone since I was playing in landscape the axis were changed. Instead of -Input.acceleration.y I had to use -Input.acceleration.x for the same movements. So if you are facing a similar problem, know that when the game is run in editor and you are using remote the axis will be different than what is run on the phone itself.