Why I cannot use a C++ UAnimInstance directly?
I'm not able to set my SkeletalMeshComponent derived class to use a UAnimInstance derived class but I'm forced to use a UAnimBlueprintGeneratedClass even though they both derive from UAnimInstance? This means that I can create UmyAnimInstance, create a BP that extends it and the set the BP generated class (BP_myAnimInstance_C) bat to C++ to assign it to the SkeletalMeshComponent. Is there any reason? I can even select from the editor my native class, but then it's no used/updated at runtime, so the animation is stuck, and this is probably due to the USkeletalMeshComponent that checks everywhere whether AnimBlueprintGeneratedClass is a child of UAnimBlueprintGeneratedClass. I'm disappointed.
asked Feb 03 '16 at 07:41 PM in C++ Programming
Cool it seems that this has been fixed in 4.11 and AnimClass has been added to SkeletalMeshComponent to take care of native animations in C++. It also seems the pipeline has changed a bit with the introduction of FAnimInstanceProxy.
answered Feb 18 '16 at 03:37 PM
Blueprints does not exist in compile time, it's not C++ code which can be compiled to native code (machine code of CPU), that why code can't directly reference it in C++ because compiler does not have anything to refrence to, in matter of fact it's can't even guarranty that it will be able to refrence it in future because blueprint file might be missing or something. So what you doing is referencing asset object of blueprint (UBlueprint or in your case UAnimBlueprint) which will make engine load the asset in runtime (keep in mind runtime also means in editor) and then you can get generated (by blueprint virtual machine) UClass* to UAnimInstance of that blueprint.
You can get UClass* of blueprint class a lot easier by creating UClass* or TSubclassOf variable and set it in defaults of blueprint, but i know it does not fit to all solutions and it requires to make a blueprint.
Epic currently working on Blueprint to C++ compiler which might allow to directly reference to blueprint classes, but animation blueprint is little bit diffrent, so not sure how it will go with it
answered Feb 04 '16 at 05:07 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here