Search Unity

How to keep camera level while tilting phone

Discussion in 'Cinemachine' started by Gametyme, Jun 14, 2022.

  1. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    I tried making the camera a child of a empty game object and tilting the game object in the opposite direction of the to keep the screen level like asphalt 8. The problem is it’s just not smooth. Is there a better way?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    You'll have to give more details about how exactly you're accomplishing this. A video would help too.
     
  3. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    Np, I can make one when I get home. Have you ever played asphalt 8?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
  5. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618

    please skip to the one minute mark to see what I’m trying to accomplish.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    ok, thanks for the video. If I understand correctly, you want to use the screen as a steering wheel, but cancel out that tilt in the camera. Detecting the tilt every frame and rotating the camera object in the opposite direction is a good way to do this. Since I don't know exactly how you're doing this or what the nature of the non-smoothness is ("not smooth" is quite a vague description), I can't really comment more.