I created 3rd Persion project and used c++(not blueprint) to create my mesh that ia all ok,
I am going to play my UAnimMontage object, but fail, code as bellow:
static ConstructorHelpers::FObjectFinder < UAnimMontage > myTestMontage(TEXT(“AnimMontage’/Game/Character/man01/man01_anim_AM.man01_anim_AM’”));
testMontage = myTestMontage.Object;
UAnimInstance * AnimInstance = Cast(mesh->GetAnimInstance());
if (AnimInstance != NULL)
mesh->AnimScriptInstance->Montage_Play(testMontage , 1.f);
but AnimInstance always is null,
Please help me, thanks.
PS: I have add AnimMontage in editor, and mak sure AnimMontage is ok.
That means your object dont have animation script/blueprint or you doing that in class constructor where thimgs are not initiated yet (use BeginPlay() event insted)
Below code are add in AMyCharacter::MoveForward() function,
UAnimInstance * AnimInstance = Cast(mesh->GetAnimInstance());
if (AnimInstance != NULL)
AnimInstance ->Montage_Play(testMontage , 1.f);
AnimInstance alway is null
Please help me, thanks.
After I create some Actor and Anim Blurprint ref sample first persion code,
AnimInstance is not null, I call Montage_Play in ACharacter tick function,
But Montage_Play is not play run animation, I have set run anim to my Montage,
In editor I found my montage can play run anim,
Please help me, thanks.
After I create some Actor and Anim Blurprint ref sample first persion code,
AnimInstance is not null, I call Montage_Play in ACharacter tick function,
But Montage_Play is not play run animation, I have set run anim to my Montage,
In editor I found my montage can play run anim,
Please help me, thanks.
link text
Have you created a named slot in the AnimBlueprint, and set the the Montage to use that slot?
Thanks very much, After I created a named slot, That is all right,
But I have many Anim to play with C++, How to add those slot to AnimGraph,
Or how to switch those in AnimGraph,…
Please help me, Thanks.
I also have many anims set up as Montages, and as long as you set the Slot Name in each of the montages to the one you set in the Blueprint, they will all be played through that slot.
Thanks, I have another problem, I have set all animation and its state in AnimBlueprint and set one variable in AnimBlueprint, but I cannot get and set its varible in my c++,
How to do it, Please help me, Thanks.
Thanks very much, Solved.