Recently I’ve been trying to set up a Character class to have a default ‘Animation Generated Blue Print Class’ (in their properties when clicking on them in the editor) as well as being able to apply a Blueprint animation class when they spawn in-game to override some specific cases.
For setting it at run-time of the game I’ve been trying to refer to the blueprint class in PostInitializeComponents and setting it by SetAnimInstanceClass on the Mesh. For the default properties I was attempting to access the blueprint by name in the constructor.
What is the proper way to be doing these things? I’ve tried searching and I’ve yet to come across any specific examples.
StaticLoadObject loads UObjects and you’re trying to cast it to a UClass which will always fail with NULL. Use StaticLoadClass instead, with the path set to “/Game/Character/HeroTPP_AnimBlueprint.HeroTPP_AnimBlueprint**_C**” or “/Game/Character/HeroTPP_AnimBlueprint”, I can’t remember which one you’re supposed to use but I’m not able to check right now.
I fixed the StaticLoadObject problem but unfortunately I still have been unable to find a way to properly reference the blueprint. For the record the blueprint I am trying to reference in code is pre-existing with the base third-person project.
This is what the current code looks like. Note that I have tried almost every variation I could think of for the “/Game/Character/HeroTPP_AnimBlueprint” section including the ones you mentioned above. As of the latest code I threw this into the Tick function so that I am positive it is getting called without anything else that may be replacing it or overwriting it.
Am I casting it to the wrong class? Referencing it wrong? I’m afraid I am currently at a loss as to what is wrong.
Also worth nothing is that for most/all of my tests the log errors do show “LogUObjectGlobals:Warning: Failed to find object ‘Class /Game/Character/HeroTPP_AnimBlueprint.HeroTPP_AnimBlueprint’” so it seems my main/initial problem is just finding out how to properly reference the blueprint.
But as you said, it’s warning you about not finding the blueprint. So if that still comes up with this code, you’ll know for sure something is wrong with the path.
It seems I should have been testing with FObjectFinder rather than StaticLoadObject/Class. I was able to get FObjectFinder working with the path above. Thanks!