Retrigger Animation every time state is entered?

I have a weird and somewhat situational problem with my animation state machine; see attached pic.

when the jump button is pressed, the player enters the “jump” state (note: the jump anim has 8 frames of windup, and uses a branch notify to fire the actual jump in the character blueprint, which is why I use this logic rather than simply checking bIsInAir) by way of a boolean set by an event triggered by pressing the jump input.

Then, the player enters the fall state when their Z velocity drops below zero (i.e. they’ve hit the peak of the jump). There’s a blend to transition between these two for smoothness.

Then, if the player hits the ground (not bIsInAir anymore), we enter the landing state, and the player can transition out of this by waiting for the animation to end OR by acting (i.e. walking or jumping cancels the landing anim early). Entering the landing state also clears the jump bool, allowing the player to jump once more.

The problem occurs if the player spends too brief of a time in the “fall” state (either because they jump into a low-hanging ceiling or just barely make the jump to a ledge) and then jumps again right away. They get stuck in the end of the jump state, floating above the ground, until they maneuver off a ledge and fall. Logically, this is what’s happening (near as I can figure):

  1. the player, upon landing, presses the “jump” key, which sets the bool the state machine uses to cancel the idle anim and then re-enter the jump state
  2. because the state machine did not finish blending between “jump” and “fall” fully, the state machine has not “let go” of the jump anim, which prevents it from resetting.
  3. the game re-enters the jump state but, because the animation is still playing (has not been “let go” and allowed to reset itself), it is too far forward in the jump anim to fire the branch notify that causes the player to jump
  4. the player IS technically in the jump state, still, but they have a Z velocity of 0, which prevents them from entering the fall state, and thus prevents them from landing, and thus prevents them from resetting the jump with further presses.

The solution would be to have an event fired by entering the transition to the landing state which resets the jump anims. Unfortunately, I can’t figure out how to do this. The event graph seems capable of resetting anim assets but this doesn’t seem to affect the state machine, just anims triggered directly from within the event graph. Am I missing something?

make sure you can always return to idle/run state. in stock animation graph of blue man, it’s just jump/in air/land/idle, you can “drive” animation with condition and it does not have to be a state machine change.
similar to idle/run, you can have the in air animation a linear blend between going up when Z velocity is greater then 0, and then blend to fall animation when below 0.
Thus when bIsInAir is no longer true, it will always go to landing(where you can branch to say ledge grab).

I think you are looking for transition events. If you select either a State, or the Transition, you will see in the Details panel “Animation State”. In there you will have events like Entered State Event. If you type a name there and compile your Blueprint, that event name will exist as a state machine event inside your Event Graph.

Step by step:
Select your State or Transition
In details panel, in Entered State Event, type an event name. (eg: MyEvent)
Compile Blueprint
In Event Graph. Right click, Add State Machine Event, MyEvent.

Or use PenguinTD’s solution. :slight_smile:

This certainly works, but WHAT DO I DO WITH IT?

I know how to trigger an event upon entering the landing, but I can’t figure out what function to call to reset the jump anims. The SetPosition anim function wants an animation asset input but there doesn’t seem to be a way to provide one from within the event graph.

I don’t know to be honest, I would have to sit down with the system and work my way through to a solution. Hopefully someone else can help you with the next part.