Why can't i dynamically load an animation BP in a packaged game ?
I can't dynamically load an animation blueprint in a packaged game.
Here is my code (i tried both LoadObject and StaticLoadObject with the same result):
So the BP is cooked, the file is there, but it can't be loaded in packaged game, while a skeletal mesh in the same directory is correctly loaded.
Is there something special with animation blueprint as a packaged object ?
Sorry if this is no bug but i checked everything i could and can't see a reason for it not to load, considering it has been cooked and the code works in PIE.
asked Jul 26 '15 at 06:38 PM in Bug Reports
Just in case anyone bumps into this problem, here is some working code to dynamically load animation blueprint.
The trick is simple: never ever use blueprint, instead, use the class Luke.
And this is it :-)
Now if you want to drive your animation state through variables, here is the bonus.
Code a class inheriting from UAnimInstance to store all your BP variables (here i created the UYagCharacterAnimInstance class that contains the AnimTest integer).
Your animBP (here IcloneAnimBP) should be created in the editor inheriting from your own anim instance class (here UYagCharacterAnimInstance) instead of UAnimInstance
As always, it might not be the best way to do this but it works.
All this is done in the PostInitializeComponents function in my code but can be put anywhere else, the point is it's not in the constructor and is entirely dynamic.
I hope this helps !
answered Aug 01 '15 at 08:43 AM
In a packaged (or 'cooked') game, dynamic loading of non-cooked content is not supported. For content to be referenced by code you would need to use the FObjectFinder in your classes constructor instead of a plain old LoadObject(). For example:
This will ensure that the packaging process picks up the fact that the game needs to reference this asset.
See here for documentation on this.
answered Jul 28 '15 at 09:11 AM
Tom Sarkanen STAFF
Thank you so much for noticing this issue with the Unreal Engine. I have verified and reported this bug to our Developers. The Jira report is referenced as: UE-19239. If you happen to have any further questions or concerns, please feel free to reply back and I will assist you further.
Have a great day!
answered Jul 27 '15 at 08:23 PM
After some more investigation, this is because UBlueprints (and derived classes, like UAnimBlueprints) are not loaded outside the editor. They are deemed to be editor-only constructs and their generated classes should be used in cooked games rather than the UBlueprint itself.
For reference, loading is controlled by UBlueprint::NeedsLoadForClient() and UBlueprint::NeedsLoadForServer().
See this question for more details.
answered Jul 29 '15 at 09:33 AM
Tom Sarkanen STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here