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.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Bug Animation resetting variables when finishing

Discussion in 'Animation' started by Carlfiii, Nov 19, 2022.

  1. Carlfiii

    Carlfiii

    Joined:
    Feb 4, 2020
    Posts:
    20
    I've spent hours trying to debug this animation but I've had no success. All I'm trying to do is have an animation disable a gameobject with a keyframe, then have that object stay disabled even after the animation ends.

    I must be missing some obvious, fundamental animation info because I've looked all around the internet and found no one with this issue.



    This is a simple animator that goes from Idle -> Animation that hides the gameobject -> A second idle state. Each transition is exactly the same:
    - Has Exit Time: True
    - Exit Time: 1
    - Fixed Duration: True
    - Transition Duration: 0
    - Transition Offset: 0
    Additionally, there are no conditions between the 3 states, so it's basically just cycling over and over.

    What happens during gameplay is it spends 1 second in Idle, transitions to PlayerTabHide, which successfully disables the GameObject about 0.8 seconds in, then immediately re-enabled the GameObject when transitioning to Idle2



    This is the PlayerTabHide animation. The first keyframe enables the gameobject, the second keyframe disables it, and the third keyframe at the end also disables it.

    The GameObject being enabled/disabled is just a UI image on the screen.

    What I've done for debugging:
    - I am running Unity 2020.3.33f1
    - I do not have any other script/animation affecting the GameObject
    - I have tried WriteDefaults both on and off
    - I've tried all the Clamp Modes for the animation
    - I've tried lots of different animation transitions combinations
    - I've tried 1 keyframe, 2 keyframes, keyframes only at the end, only the beginning, etc
    - The animation is not being affected by the Animation Tab Preview
    - Animator.keepAnimatorControllerStateOnDisable has no effect

    If anyone knows what's wrong PLEASE help me. Whenever I try to enable/disable GameObjects with Animations it causes a complete breakdown. I akways have to enable the gameobject at the beginning of the animation before I can disable it, which doesn't seem correct to me.
     
    AEXII likes this.
unityunity