Download

Jump Animation Won't Play

I have NO clue why the animation won’t play, even though Im new to animations in C++, I have no idea why. Any help would be Massively appreciated
void Jump and void Stop Jumping'.PNG

Try Getting Mesh and Anim Instance then use Montage_Play().


GetMesh()->GetAnimInstance()->Montage_Play(MyMontageClip);

Also make sure the animation has the slot setup.

Ok I’ll try this now

Edit: It’s still not working. Is there like a tutorial for jump montages in c++ or something?

In your character .h file (public section) add:


UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Gameplay)
class UAnimMontage* MyJumpAnimMontage;

In your character .cpp file add this include to the list:


#include "Animation/AnimInstance.h"

and in your jump part make it look somewhat like this:


void AMyProjectCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
Jump();
UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance();
if (MyJumpAnimMontage && AnimInstance)
{
AnimInstance->Montage_Play(MyJumpAnimMontage, 1.0f);
}
}

Assuming your animbp is set to use the default slot for the montage, and in its locomotion it doesn’t have any animation already set for start,loop,end jumping, it should play the montage each time you press jump

Edit: ignore the touch part, I used the default third person template as an example, use your jump function there instead.

@SB1985 I tried that and now every time the character jumps, unreal engine just crashes

Works here, I personally wouldn’t use a montage for jump, but it doesn’t crash. Copy paste how you added it to your project, the one in the example is from a default third person c++ template.

PS you can see an example of how to play a montage in the first person c++ example

@SB1985 Ok will do, also what do you mean by animBp set to right slot? Im sorry if I’m asking basic questions btw.

It’s used to set things like “upper body” for example, but if left at default and without any layer blends, and put at the end it will play the montage for the entire thing, like this:


And also in the locomotion itself make sure there aren’t any jump start, loop, end that would override your montage based on IsInAir or something (it’s how it’s usually done, and recommended), and also make sure in your montage you set blend in and blend out to fit your animation, if it’s too short then 0.25 is too much.

@SB1985 You said you wouldn’t personally use a montage for the jumping anim. Is there anyway you could show me or give me a link to a tutorial on what you would do?

Sure BP 3rd Person Game: Building the AnimGraph | 10 | v4.8 Tutorial Series | Unreal Engine - YouTube

but basically jump start > jump loop > jump end