Help with casting to character controller

Hello there!

I am working on a project in where a player is able to double jump. I have a jump counter keeping track of how many times a player presses the ‘jump’ button, which resets when the player touches the ground.

This all works great, but now I am trying to cast the ‘jump counter’ variable to my eventgraph for my animation blueprint, and it doesn’t appear to be casting.

The variable is an integer called ‘Jump Count’, and is attached to the thirdpersoncontroller blueprint.

Inside of my eventgraph for my animation blueprint, I have a ‘TryGetPawnActor’, and then cast to ‘ThirdPersonController’, to where I use the ‘Get Jump Counter’ node, followed by an ‘integer ==’ branch and a condition to see if jump counter is equal to 2. If it is, set the ‘Jump Twice’ bool (on the animation blueprint) to true so I can execute the transition.

If not, set it to false.

I attempted to throw in a print statement after the ‘get jump counter’ variable on the cast to the player controller, but it doesn’t print anything when I jump.

I have attached how I have my eventgraph on my animation blueprint setup.

I’m still somewhat new to blueprints and UE4, but trying to learn as I go, and cannot seem to get this to work.

Thanks for your help!

Hello :slight_smile:
I guess TryGetPawnOwner node returns the PlayerCharacter, you should use GetController from the output and then try to cast that. something like the screenshot.

Hey! Thank you for your comment. I ended up reversing the order I did things, and was able to get it figured out.

I ended up casting to the animation blueprint from the character blueprint, and set the animation variable from there which worked out.

I ended up reversing the order of this operation, and instead of casting to the player controller from the animation blueprint, I casted to the animation blueprint from the player controller. This allowed me to set the ’ Jump Twice’ variable directly on the animation blueprint which worked out nicely.