Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

gyroscope in the new input system

How do i use the gyroscope using the new input system also which one should i use the gyroscope or the accelometer?

Im trying to achieve something that when i turn my mobile my view rotates. kinda like the first person controller on mobile

Answers

  • Use the accelerometer.

    It will give you a Vector3 that represents the relative direction of gravity to the device.


    Perfectly upright would be: (0, -9.81, 0), normalized that would be (0, -1, 0)

    Rotated 90 to the left would be: (-9.81, 0, 0), normalized to (-1, 0, 0)

    90 to the right is: (9.81, 0, 0), normalized to (1, 0, 0)


    the last one is positive because gravity is now matching the + right direction of the device.


    NOTE: if auto rotate is on, the device's local facing will rotate with it. So in landscape mode, up, becomes what would be left or right in portrait mode.

Sign In or Register to comment.