I cannot implement the Jump State into my character [Pawn]

Hello guys,

I’m making a character from scratch and i have an issue adding the Jump state to the Character blueprint.

Firt of all, i know that i’ve thousands of tutorials about animations and machine stats, but in this case, my character isnt a CharacterClass BP but a Basic Pawn guy (which makes everything more difficult).

In the machine state > [Idle/Walk/Run state] condition to [StartJump state] i’ve IsJumping bool but i dont know how to “use” that bool into my main BP.

imagen

In my main BP (BP_MyPawn) i use a line trace to know if my pawn is touching the floor and using that info i can set IsGrounded to know if i’m already jumping or not (This is used as my own IsFalling)

Now i’m trying to update the code so i can use the Is Jumping (from the BlueprintAnimation), but i always have an error while casting 'cause i dont know what i need to connect to the Object input

Your animation blueprint

There’s no need for a cast there.

Also, as a general rule, casting on tick is a bad idea. If you find yourself needing to do that (and it looks like you don’t here), then it’s best to do the cast once on BeginPlay, then store the actor as a variable.

It’s also worth having a look at how gravity and ground detection is handled on the Character Pawn. You can find it in the C++ code. Basically, the gravity vector is always trying to move it down, but it has Sweep enabled, and when the Sweep detects a collision, it breaks off a Hit Result and determines if your fall has been blocked. Probably not hard to replicate in blueprints, if you wanted to go that route.

EDIT

Oh, I forgot to show how to reference it in the Animation Blueprint!

In your MyPawn animation blueprint, go to the Event Graph and make sure that the ‘Update Animation’ node is checking for the ‘IsJumping’ bool value on your pawn actor:

Ok guys, i fixed the Cast adding SkeletalMesh > get anim instance and then fixing the bool at the AnimBp

About the casting on tick, i’m not sure but in this case i need to check all the time if is touching the floor in order to jump or not?

The animation blueprint should be checking all the time. That’s what the ‘Event Update Blueprint Animation’ node in the animation blueprint’s Event Graph is doing. There is no need to keep constantly casting, because you can cast once on initialization (see the reference image I included) and store the player pawn as a variable for future use. So you only need to cast once. Casting is expensive and runs the risk of drawing a null result under the wrong circumstances, which can crash your game if you’re not careful. Casting dozens of times per second, while your game is running, is not something you want to do.

Also, it sounds like you’re trying to manipulate your animation blueprint from your pawn blueprint. That’s backwards from how that is typically handled. If you’ve properly linked your animation blueprint and the pawn, and your animation blueprint is monitoring for changes in the bool variable on your pawn blueprint, then everything else should take care of itself.