How to get morph target value on animation?

Hi people!

I’m running tests to implement something in the near future, but to it work I need a simple thing (that I couldn’t make).

I need to read the value of a morph target while an animation is running…

You will understand better watching to this video that I recorded from my testing:

Thanks thanks!

Sorry,It might be a little late but may help somebody:
did you try to use “Get morph target” node in your pawn class?
Lem me know if it works for you.

Oh, yeah, i manage to solve this… unfortunately that’s not right way to get the morph target value be cause it’s getting the value from the SkeletalMesh default pose. In order to get the morph target value from the curve animation you have to do a little of C++ to access the animation curve being played. This way you can get any value in runtime during any animation (from 0 to 1).

2 Likes

glad to hear that. and thanks for the information.

Hi Fireapache :slight_smile:
I’m trying to solve the same problem!
If you want to share your solution it would be Super helpful!!
Thanks in advance :slight_smile:

richardek, it’s easy to get this value on C++, you just have to get the animation instance for your character and there you can access MorphTargetCurves.Find(MorphName) and that’s it!

Never used C++ before but managed to get it working :stuck_out_tongue: Thanks Fireapache! :slight_smile:

USkeletalMeshComponent* skelComponent = Cast<USkeletalMeshComponent>(GetOwner()->GetComponentByClass(USkeletalMeshComponent::StaticClass()));
UAnimInstance* animInstance = skelComponent->GetAnimInstance();
TMap<FName, float> tMap = animInstance->MorphTargetCurves;
FString value = FString::SanitizeFloat(tMap["BrowsD_L"]);
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, value);

I put the code in an Actor components tick function and added the component to the skeletal mesh

2 Likes

So that no one else find their way to this post and gets stuck trying to figure out how to implement that code for half a day (seriously you need to include the .h and .ccp to make sense of getting that to work for non-programmers) I have found that there are two nodes for the morph targets.

First is Get Morph Target which only gives you the base pose value, but the second one is Get Curve Value that gives you the morph target value during play. You won’t see it if you drag of the mesh because you need to get the Anim Instance for the mesh, There is a screenshot below showing both methods (the one connected gives you runtime values for the morph target).

4 Likes

Thank you everyone. Saved me so many hours

I got the error C2039: ‘MorphTargetCurves’: is not a member of ‘UAnimInstance’?

wow THANK YOU. I was stuck on this for a few days. cheers!

to help future googlers find this:
playing an animation (anim sequence) on a skeletal mesh has get morph target/GetMorphTarget always returning 0. The solution is knowing about anim curves. The curves of the anim instance are getting set. To make matters more complicated they are not setting the morph targets, but the curves are take their names from the morph target names in the skeletal mesh. This is convoluted and unintuitive. Unless there’s something I’m not understanding, setting the morph target manually gives you the same result as setting the curve, so getting the morph target should be the same as getting the curve.