Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Accelerometer

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

  1. carlo_orlito

    carlo_orlito

    Joined:
    Aug 31, 2021
    Posts:
    4
    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

    sudoku1v2

    Joined:
    Jan 2, 2018
    Posts:
    6
    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

    tjmaul

    Joined:
    Aug 29, 2018
    Posts:
    467