Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Bug Completely empty animation clip updates game object properties

Discussion in 'Animation' started by graybear209, May 19, 2021.

  1. graybear209

    graybear209

    Joined:
    Nov 18, 2018
    Posts:
    11
    I created an "Idle" animation clip with no properties (there are no key frames, nothing is changed). While "idle" I want the object (a card) to do nothing, no property changes from whatever state it's currently in (dealt, hidden, showing, etc...).

    The editor state of my card prefab object has everything visible so I can view it in the inspector. However, when my game starts on Awake() I set the GameObject.setActive(false) for all game objects containing visible components to hide the card.

    The perplexing behavior I've observed is this:
    1. In Awake() all visible components are setActive(false); in a script
    2. In Start() all visible components are still (correctly) activeSelf == false;
    3. In the first frame of Update() my "Idle" animation (correctly) begins to play
    4. Immediately after my "Idle" animation starts, all visible components activeSelf == true (WRONG! WHY??)
    The above is observed via Debug.Log.

    Additionally if I explicitly set my visible components' activeSelf = false at the start of my "Idle" animation clip, everything works as expected (but this is not what I want to do as sometimes I want to idle while the card is visible).

    Currently there is no other code referencing my Card prefab/instance and within my Card script I only set Animator property values to control which animation is played. So I can't imagine any other variables/code/behaviors that could be at play here besides my animations.

    Why are properties changing when none are set in my animation clip? Is this a bug? Is this expected behavior?

    Thanks.
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,605
    The animation system always writes to every value animated by anything in your Animator Controller every frame.

    As far as I know, there's no way around it, which is why I prefer to use a tweening system for UI stuff.
     
    graybear209 likes this.