Search Unity

Disappearing GameObjects in Cinemachine-controlled cameras

Discussion in 'Cinemachine' started by Screenhog, Sep 28, 2017.

  1. Screenhog

    Screenhog

    Joined:
    Jul 2, 2009
    Posts:
    498
    I've been starting to learn Cinemachine, and I've encountered a strange bug. Within a camera that is controlled by cinemachine, an animated GameObject will sometimes disappear. For instance, it'll walk by the camera and then be invisible for a few frames before becoming visible again.

    Here are the things I know.
    • The frames where it disappears are somewhat consistent. It's usually the same frames that disappear when I'm travelling forward in time, but when I scrub backwards, those frames magically appear and others disappear.
    • It happens in Edit Mode and Play Mode.
    • It only seems to affect objects in motion. Other animated objects or still objects in the scene are unaffected. It doesn't matter whether or not the camera is following the moving object.
    • When I change my field of view to be wider, the character does not disappear any more. (It makes me think it's a view frustum issue, but the character stays in the middle of the screen at all times.)
    • The disappearing frames are usually when the character is closest to the camera.
    Should I try reporting this to Unity? Has anyone else encountered this?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    @Screenhog Sounds like a near clipping plane that's too far. Can you post an image of the vcam inspector?
     
    Last edited: Sep 29, 2017
  3. Screenhog

    Screenhog

    Joined:
    Jul 2, 2009
    Posts:
    498
    I'll try to get something tomorrow. Unity just crashed with a maxCallback bug (unrelated to Cinemachine). But I was able to make the character disappear even from far away, as long as the character was near the edge of the screen. I'm pretty sure I must be setting something up wrong.
     
  4. Screenhog

    Screenhog

    Joined:
    Jul 2, 2009
    Posts:
    498
    All right, I've captured it here. As you can see on the ground, there are supposed to be two characters in this shot, but only one character is actually showing up. (Both shadows can be seen on the ground.) The Near Clip Plane of this camera is set to 0.1, and the characters themselves are about 2 units tall, so it doesn't seem like it should be that.
     

    Attached Files:

  5. IBuro

    IBuro

    Joined:
    Jul 7, 2017
    Posts:
    3
    Hi Screenhog!

    Perhaps it's a little too late, but I'm actually getting this same issue.

    Reading your comments, I came to think that the problem perhaps is that the object initiates it's movement outside of the camera frustum, so the camera settings culls such object.
    It's clearly a strange bug, and it shouldn't happen, but changing some of the culling options might be a workaround.
     
  6. ErnestoBananez

    ErnestoBananez

    Joined:
    Sep 23, 2014
    Posts:
    16
    Again, probably too late, but I had the same issue with the 2D version of the Cinemachine camera. For me, changing the Orthographic Size ever so slightly (adding .2) on the Cinemachine camera script fixes the issue completely.
     
  7. NorthStar79

    NorthStar79

    Joined:
    May 8, 2015
    Posts:
    88
    Just encountered the same problem. this bug is still a thing in Unity 2018.3.0b7 and Cinemachine 2.2.7

    Here my observations about the bug and how I work around it.
    I guess Cinemachine is using some kind of hierarchical culling, means if "the parent" is outside of frustum "children" are culled too, no matter what. Probably for performance reasons. But this leads to a "bug" that if "parent" stays still and "child" moves and camera follows child's transform. The easiest workaround of this is just un-parenting that game object. but I must say that this may be not an option all the times. So at least there should be an option to disable hierarchical culling completely or just for some gameobjects.

    I hope this helps people.
     
    Menion-Leah likes this.
  8. cloverme

    cloverme

    Joined:
    Apr 6, 2018
    Posts:
    198
    Confirmed, this bug sucks.

    I needed an over-the-shoulder vcam to dynamically enable with an animation on a 3d gameobject that would become active at the same time. Well, part of the animated gameobject is outside of the frustum, so the vcam wouldn't show the gameobject unless the entire gameobject was in-view. However, if you clicked on the Scene window, the object would appear. This was a nightmare to troubleshoot, tried several ways to adjust the camera, layers, clipping, etc. The only method I was able to get to work consistently is a kludgey workaround, but it fixed my issue 100%. I had to set the scale of the gameobject to 0.0001f so it would technically "render" the entire gameobject from Unity/Cinemachines point of view, then when I needed it to appear, I could scale it back to 1f. Just leaving this here unless anyone finds this in the future and needed another alternative "fix".
     
  9. Hunter-PrimeUnity

    Hunter-PrimeUnity

    Joined:
    Sep 6, 2020
    Posts:
    4
    I have found an alternative fix for this with a particular bug I'm encountering.

    I discovered that the camera was culling objects with a Skinned Mesh Renderer when their bounding volume was outside of the camera frustrum. You can tweak it in Bounds settings in the Skinned Mesh Renderer and see it as a white cube gizmo in the editor. You can test it yourself. Play your scene, select one gameobject with a Skinned Mesh Renderer component, go to the editor tab and you will see the object disappear as soon as the white cube gizmo representing the bounding bog is outside of the camera view.

    My character have armor plates and their bounding volumes doesn't correctly follow the mesh when he is crounching. This made them disappeared when the camera was too close. My fix is to tick Update When Offscreen in the Skinned Mesh Renderer component.

    I'm guessing this can have be performance issue if you do it too much but I think it's ok for just one character.
    Hope this helps.
     
  10. TheAmazingKiddo

    TheAmazingKiddo

    Joined:
    May 21, 2021
    Posts:
    4
    Hi guys, again, maybe way too late but what worked for me was, going to the object that was disappearing and checking the "Update When Offscreen". Totally worked for me.
     
    GiftedMamba likes this.
  11. hunabku94

    hunabku94

    Joined:
    Jun 12, 2017
    Posts:
    50
    Hi guys, again, maybe way too late but what worked for me was, going to the object that was disappearing and checking the "Update When Offscreen". Totally worked for me.