GetSkeletalMeshComponent()->GetAnimInstance() returns NULL
Hello! I am creating a Bow and Arrow for VR. The bow was created in C++ and was inherited from the SkeletalMeshActor. The actual mesh is populated when its instance is dropped in the level. I have a bone on the bow string so my player can pull it back with the motion controllers. To accomplish this, I am using a custom AnimInstance class to set custom variables for that bone's location. The tutorial below helped me accomplish this:
I followed the step-by-step instructions and produced the following custom AnimInstance class:
On the BP side, I created the bow's Animation BP and reparented it to my custom AnimInstance class. I can successfully access those variables in the Animation BP.
In the level, my bow instance has the skeletal mesh attached and notes to use the Animation BP and the Anim Class:
I added some code to test the AnimInstance out, but the test for its existence came out as NULL.
Is there something obvious I have forgotten to do to access the AnimationInstance I have created?
In addition, this is my Animation Blueprint for the bow. I'm fairly new to using this system, so be kind if the problem is obvious! :P
Hi, this is most likely because actors are not guaranteed to exist at construction time (and they most likely will not, the world might not exist at that point). All actors will be initialised by the time BeginPlay is called, which I believe is the most suitable for what you are trying to achieve (use BeginPlay instead of the constructor).
Follow this question
Once you sign in you will be able to subscribe for any updates here