Search Unity

Small question about input.acceleration

Discussion in 'Getting Started' started by ShinigamiUzi, Dec 22, 2018.

  1. ShinigamiUzi

    ShinigamiUzi

    Joined:
    Sep 5, 2017
    Posts:
    54
    I want the max amount (-1/1) to be reached on small tilts of the phone, currently, you need to tilt the phone almost 90 degrees to the side to get (-1/1) input, this gives me decent results (multiply current input by some amount so the phone reaches (-1/1) on smaller tilts) however is there a better way to do it so this scales better ?

    Code (CSharp):
    1.         horizontalInput = Input.acceleration.x * 5;
    2.         horizontalInput = Mathf.Clamp(horizontalInput, -1, 1);