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.

Resolved Animator Culling Mode "Cull Completely" seems to be working incorrect

Discussion in 'Animation' started by kumade, Nov 2, 2022.

  1. kumade

    kumade

    Joined:
    Nov 3, 2016
    Posts:
    52
    Hey everyone! I have an issue with animation culling opposed to what people are usually asking about (like "why does my animation still play when the object is invisible", I have quite the opposite).

    I have different types of enemies. They have the same prefab layouts with the only difference that some of them I animated in Unity editor (used MeshRenderer for their mesh and animated only basic transforms) and some have animations imported from *.fbx (they have SkinnedMeshRenderer and bone-based anims). All animators for both types of enemies are set to "Cull Completely".

    So the enemies that have simple MeshRenderers (not Skinned) play animation when visible and do not play when out of the camera frame. Everything works great!

    The ones with SkinnedMeshRenderer always have their animations not working no matter the camera frame position.
    Bounds in the SkinnedMeshRenderer component are set correctly, I can see them when I press "Edit Bounds".
    And nothing covers the objects, they're fully visible on a test scene.
    And I tried playing with "Update when offscreen" option - no effect.

    If I change culling mode to "Always animate" they start moving but I don't want that as it's just wasting of resources.

    My Unity version is 2020.1.17f1.

    Any chances someone knows how to fix this?
     
  2. kumade

    kumade

    Joined:
    Nov 3, 2016
    Posts:
    52
  3. kumade

    kumade

    Joined:
    Nov 3, 2016
    Posts:
    52
    Nope, updated to 2021.3.12 and still having the same behavior. Please oh Unity gods came down to me and tell me what am I doing wrong?
     
  4. kumade

    kumade

    Joined:
    Nov 3, 2016
    Posts:
    52
    Ok a few images of what I have: on the first screenshot you could see a camera not looking at the objects (WorkingActor and NotWorkingActor in the hierarchy). They both have their Idle animation state active but not playing the animation cause they're not in the frame. Both Animators' culling mode set to "Cull Completely".


    Next I have moved the camera so both actors are visible. Now WorkingActor animates as expected (see Idle state progress bar and changing transform values) but NotWorkingActor stays still (no Idle state progress bar moving)
     
  5. kumade

    kumade

    Joined:
    Nov 3, 2016
    Posts:
    52
    Alright I've found what was this all about. The game object I'm having my Animator component on (the one called Armature inside NotWorkingActor on the screenshot above) doesn't have any MeshRenderer nor SkinnedMeshRenderer in it's hierarchy (it and its children) - the SkinnedMeshRenderer component is on Model object which is a sibling to the Armature. This hierarchy is imported from blender and cannot be changed unless I break prefab and rearrange objects (which I don't want to)
    While WorkingActor has MeshRenderer on one of his children called Mesh. This makes the difference.
    Unity seems to be thinking that the NonWorkingActor is always out of the camera frame. As soon as I add Model object under Armature (beaking prefab) OR add MeshRenderer to the Armature - the culling begins to do it's job and the animation starts working when the object is visible by a camera.
    So my solution to this problem at the moment is just add MeshRenderer with disabled shadows and other options (to make it more lightweight) to the game object containing Animator with culling more set to Cull Completely.
     
    Last edited: Nov 6, 2022