Dear experts,
I try to call a Montage from C++ and the code looks like this. However, the UE_LOG in red never gets called:
My AnimInstance I think is a nullptr. But why?
I am setting up the character with “SetMasterPoseComponent” and on the Jacket I set the Animation Blueprint:
How is it that my AnimInstance is null? Any ideas what I have to look for?
Thank you
pladux
(pladux)
July 10, 2022, 9:26am
2
Have you verified CombatMontage is actually set? You should really be using a debugger. Makes things a lot (I mean a lot!) easier.
Hello Pladux
yes, even in the debugger I can see that the UAnimInstance I have is null:
All I am doing in the .h file is this:
UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="Movement")
UAnimInstance* AnimInstance;
Do I have to set it in the Constructor or BeginPlay() ? I thought it is there automatically.
I realized looking at this: https://forums.unrealengine.com/t/how-can-i-get-skeletal-mesh-animinstance-and-then-cast-it-using-code/283271
that I have to change some code. I did that and it looks better, AnimInstance does not show a NULL anymore:
But still when I test play the game, the montage “AM_Sword” is not played when I attack. Do I need to anything in the animation blueprint? I only created the montage “AM_Sword”.
found it, I have to add a “Slot” for the montage within the animation blueprint: