So I’m trying to attach an actor to a Pawn’s bones, but the attached actor uses the bone locations from the previous frame instead of the current one.
My game logic needs to run like this:
- Update the pawn’s variables that affect the animation
- Update the pawn’s animation based on the variables
- Update the attached actor’s location based on the new animation
I set the Pawn’s skeletal mesh component to PauseAnims, because I need the animation to update in the middle of the Pawn’s Tick event.
Here’s how I tried to debug it, in the Pawn’s Tick event:
UpdateAnimVars();
Print(m_skeletalMeshComponent->GetBoneLocation(TEXT("Elbow_R"))));
m_skeletalMeshComponent->GetAnimInstance()->UpdateAnimation(DeltaTime, false);
Print(m_skeletalMeshComponent->GetBoneLocation(TEXT("Elbow_R"))));
UpdateAttachedActorLocation();
I also print a debug message in the Event Graph of the Animation Blueprint, which prints out between the Elbow position messages, so I know it’s executing the Event Graph at the correct time.
The Elbow position messages both print the same vector, so it seems that UpdateAnimation doesn’t update the bone locations.
I also tried calling all of these between the Elbow position messages, but none of them changed anything:
m_skeletalMeshComponent->TickAnimation(DeltaTime, false);
m_skeletalMeshComponent->TickPose(DeltaTime, false);
m_skeletalMeshComponent->FinalizeBoneTransform();
So is there any way to force Unreal to update the bone positions in C++?