Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Accelerometer

Discussion in 'Physics' started by carlo_orlito, May 14, 2023.

  1. carlo_orlito


    Aug 31, 2021
    Hi Guys ,

    I'm using accelerometer in my mobile game.

    Input.acceleration.x and Input.acceleration.y

    Does anyone know if it can be done in real time so that the range of movement of the character is the same as the player holds the phone horizontally or vertically relative to the ground?

    If not, at least can it be set so that the user can choose when starting the game whether he will hold the phone horizontally or vertically and on this basis the player will be positioned?

    Big Thanx
  2. sudoku1v2


    Jan 2, 2018
    In general, the mobile phone accelerometer gives an acquisition in absolute value, meaning that :
    - the acceleration on X and Y axis (horizontal one) are closed to 0
    - the acceleration on Z axis (vertical axis) are closed to g = 9,81 m/s2
    when the mobile phone is horizontal and fixed.

    The value will be higher if you move your phone with acceleration.
    Try also to put phone vertically, then you measure the earth acceleration g on the X or Y axis.

    You can load on playStore the "Droid Info" application to get real time measurements.
  3. tjmaul


    Aug 29, 2018