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

Resolved Checking for mobile device angle changes

Discussion in '2D' started by Crazybrownie204, May 4, 2021.

  1. Crazybrownie204

    Crazybrownie204

    Joined:
    Mar 22, 2021
    Posts:
    23
    So I want to make a mobile app where the angle of the camera moves with the angle of the screen, so that the screen is always facing up (As in up in real life). Is their any way to do this? Any help would be much appreciated. By the way, I am talking about 2d, not 3d.
     
  2. M4dR0b

    M4dR0b

    Joined:
    Feb 1, 2019
    Posts:
    108
    Y-Hello there,

    to check physical device orientation you have to access its sensors like Gyroscope and Accelerometer. With those you can know exactly what is the orientation of the device and if the user is rotating it, or moving it (like shaking for example).

    Here you can find some references:
    https://docs.unity3d.com/ScriptReference/Gyroscope.html
     
  3. Crazybrownie204

    Crazybrownie204

    Joined:
    Mar 22, 2021
    Posts:
    23
    Thanks! But I don't really know how to use it. I would only need part of it, and the 2d camera needs to move with the clockwise/counter-clockwise movement of the phone. Do you have any idea how to do that? Any help would be much appreciated!
     
  4. M4dR0b

    M4dR0b

    Joined:
    Feb 1, 2019
    Posts:
    108