Triggering state changes

Seems that the accepted way of triggering animation state changes is setting a variable in the AnimBP from a value in some other BP. Assuming this is a boolean value, and the transition rule fires when this is true, what needs to happen in order to then set it to false to prevent the anim re-triggering when it returns to the initial state?

what kind of animation are we talking about here? if its a one-off it might be best to pop a Anim Montage instead of a state.

It’s to move from an idle anim to one of several possible “do action then return to idle” anims. So I could have an integer variable in the AnimBP which gets a value from another BP in the UpdateAnim event. If it’s zero, do nothing. Non-zero should trigger one of the N transitions. Then I need to reset the variable to 0 once the transition fires to prevent it re-firing next time around.

I will look at montages again to see if they help :slight_smile:

Oh, it looks like there is a “Start Transition Event” that fires when a transition (er) starts, and I can reset the trigger to 0 in a handler in my character BP from there (?)

i think this really depends on your game logic and how you filter your input. im still not sure what you want to acomplish with “prevent the anim to retrigger when it returns to the initial state”…do that means you want the anim to be triggered only once in the whole game? because if its an attack or jump or w/e animation, it is expected to be able to trigger again after the action is completed.
Eventgraphs on Anims are no different than blueprints. you can add a animNotify at the end of the animation and that notify will trigger an event inside the Eventgraph of the anim. you could add a simple boolean that closes that branch of the animation if you dont want the character to be able to repeat that animation.

It’s a turn-based RPG-style thing. I have a character in the IDLE state. The player selects a menu command - say for the sake of argument it’s “cast spell”. The menu command should trigger the state machine to transition from IDLE to “CAST” by setting an Anim variable from 0 to 1. The transition rule for CAST tests to see if Anim == 1, and if so, starts the transition to the “play CAST animation” state, which will play once, then return to IDLE. At this point, if Anim was still 1, the transition rule would re-trigger and the state would change again. So something has to change the Anim variable back to 0 to stop the rule firing again (which I propose is the Start Transition Event handler). Of course it can be re-triggered when the player selects the next command on the next turn.