Search Unity

Cinemachine randomly changes view by 180 degrees

Discussion in 'Cinemachine' started by Oktopod, Jul 7, 2019.

  1. Oktopod

    Oktopod

    Joined:
    Mar 10, 2018
    Posts:
    4
    Hello everyone, first time poster since almost all issues that I have had in the past were easily resolved with a quick google or forum search.
    I have recently switched to Cinemachine as oppose to just making the camera a child of the player. Everything was working fine, unitl recently, without any settings changes that I can just undo, the camera just randomly switches to looking at the player from the opposite position. Sometimes it stays like that, sometimes it lasts for 0.1 seconds. I have only one virtual camera in the scene, so this is not related to blending or transitioning from one camera to another. The same camera just flips. Does anyone know what I can do. I will post screenshots of this random flip to provide more context. The biggest problem is that this happens 100% randomly. It is not consistent. Sometimes it never happens, sometimes it happens once in the level, sometimes multiple times, very rarely in the same spot in the level. I have googled for hours with no results.
    Thank you in advance!
     

    Attached Files:

    Last edited: Jul 7, 2019
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Can you show an image of the inspector for the vcam?
     
  3. Oktopod

    Oktopod

    Joined:
    Mar 10, 2018
    Posts:
    4
    Of course. Can't believe I forgot that
     

    Attached Files:

  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Hmmm... it all looks pretty normal.
    Does the flip happen in a single frame, or does the camera damp its way around?
    Can you show an image of the CM Brain inspector too?
    Are you doing anything weird with the target's rotation? Or the world up override?
     
  5. Oktopod

    Oktopod

    Joined:
    Mar 10, 2018
    Posts:
    4
    I will post the player settings also just in case, along with this link: https://imgur.com/a/5pvZ2Ck where you can see the recorded footage of this issue. I was lucky to capture it happening both for 0.1 seconds as I described, AND changing and staying that way. Hope it provides some insight. As for the target's rotation, not that I know of
     

    Attached Files:

  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    aahh! You are doing something with the player rotation: it's turning upside-down, which makes its forward face backwards. Since you're binding to target's local rotation, your offset flips around relative to the world, but stays constant relative to the target. Try changing the binding mode to World Space.
     
    Last edited: Jul 8, 2019
  7. Oktopod

    Oktopod

    Joined:
    Mar 10, 2018
    Posts:
    4
    You are a god. That fixed it! Thank you soo much! I've played through the level multiple times trying to find the spots where it flips most often but the issue didn't show up, not even once!
     
    Gregoryl likes this.
  8. Franc3spo

    Franc3spo

    Joined:
    Jul 14, 2021
    Posts:
    3
    Hi, changing the binding to world space stops the camera from rotating along with the target's rotation. Is it possible to prevent the 180° turning while maintaining the rotation feature? (In my case I'd only need the camera to rotate along with the target's y rotation)
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Try "Lock to Target with World Up"
     
  10. Franc3spo

    Franc3spo

    Joined:
    Jul 14, 2021
    Posts:
    3
    I'm using it, but when my target's (which is also the "look at") x rotation reaches 180°, the camera goes to the opposite point. I'd like the camera to follow along with the y rotation, is there any workaround? The result i'd like to achieve would be a mix between "simple follow with word up" and "lock to target with world up"
    Immagine 2023-07-17 214412.png Immagine 2023-07-17 214655.png
     
    Last edited: Jul 17, 2023
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    I think the best way to deal with this would be to create an intermediary invisible object to use as camera target. Give it a custom script so that its position exactly matches the player position, and its rotation matches but with up pointing up. You'll have to work out a strategy to handle the situation illustrated (maybe forward can be held over from previous frames, before the x rotation became 90). Use the invisible object as camera target instead of the player.