Search Unity

How do I limit the rotation of the gyro on my camera?

Discussion in 'Editor & General Support' started by Eco-Editor, Jun 19, 2019.

  1. Eco-Editor

    Eco-Editor

    Joined:
    Jun 29, 2016
    Posts:
    71
    Hello everyone,

    I’ve searched the web for answers but the found only scripts that limit the rotation so that the gyro responsive to one axis or more.

    My goal is to have the gyro responsive to X and Y axis, however instead of full rotation of 360 degrees, I need the rotation to be limited for 90 degrees only, for example, minimum of -45, and maximum of 45 on each axis.

    So I’ve been told to use Mathf.Clamp and clamp the rotation of the gyro.attitude.eulerAngles in a local variable.

    How would you approach this?