Setting a C++ Variable at the end of an animation?

Hey,

I’m creating a simple Side Scroller (based off the Side Scroller C++ template) for an artist, in which a character is placed in a simple environment and can Run, Jump and Attack.

The Issue I’m having is with the Attack. The artist doesn’t want the user to be able to move the character during the attack animation. Being a programmer, I opted to place a variable (bool) inside the Character code that is set to true when the left mouse button is pressed (Using a Action Bind). This variable is then used to stop the movement and jumping code from running if the variable is set to true.

During the Animation update, the EventGraph is able to access the variable, by using a Cast to the “MyCharacter” blueprint, in order to get the variable to enter the attacking state. However, I want to set the variable back to false when the animation has ended. I simply can not find a way to access the variable in the state transition (between Attack and Idle) blueprint to set it back to false. I’ve tried getting the owner and casting, just like in the EventGraph, but this does not get executed unless something is placed before the Cast function.

So my question is, Is there a way to access a C++ variable from a Animation State Transition blueprint? Or is there a better way to do this that I’m just not thinking of?

This could be better explained in pictures, but unfortunately I’m not home at the moment to make them. If anyone need further explanation, feel free to ask.

So, is the problem that you don’t have any event generating the “execute” white line for the “cast” operation?
If so, you may be able to listen to a notify when the attack animation ends. That notify is an event, and you can use that event as the source for your “setting boolean to true” action.
For more information, see Animation Notifies in Unreal Engine | Unreal Engine Documentation

This works fine! Thank you for the help :slight_smile: