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?
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?
Comment