How can I recover a reference to an asset on C++?

Hi there, sorry if this was asked before but i simply couldn’t find an answer for it. What I am trying to do is to animate a character from C++. I know i must create an AnimMontage for the character and pass it to PlayAnimMontage. What I can’t find is how to reference my anim montage from C++ code without exposing a property. I tried:

ConstructorHelpers::FObjectFinder < UAnimMontage >  GuardWalkMontage (TEXT("AnimMontage'/Game/Animations/GuardWalkMontage.GuardWalkMontage'"));

to get the ->Object member but when code reach this line, everything explodes and unreal editor quits. I am a bit lost, since I started to mess with Unreal engine two days ago. Thanks for the help and keep up the great work!

Did you tried debugging?

#.h

Put this in a .h for a class that you’ve blueprinted, like character or player controller

UPROPERTY(EditDefaultsOnly, Category=JoyAnims)
UAnimMontage* Swing2Running;

then in the editor, you can select which montage to use

the fabulous advantage of this

is that if you do this in a base Character class

you can then select different actual animations for each subclass of this base class!

Rama

Just to make sure, you know it’s
GuardWalkMontage.Object
and not
GuardWalkMontage->Object

Not yet. I am more interested if this is the correct way to retrieve the reference rather than knowing why it crashes. If FObjectFinder is the way i’ll look more deeply into it.

Yep, I’ve been programming with C++ for over a decade now

Sorry but I don’t really want to expose a property, I let that clear on the question.