Animation resetting variables when finished

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.

the problem is your event is getting fired again on the transition between animation clip

so check your transition values and better to make it 0 if you don’t need blending