Post animation update in C++

I get a bone’s position using USkinnedMeshComponent::GetBoneLocation in my character 's tick function. But I find the value seems to lag a lot. I guess it’s because the tick function doesn’t always get called AFTER animation update. So my question is: is there a post animation update function callback/event in agent of actor? If there isn’t, how could I get sync bone position in C++?

Thanks!

When your animation ends you can add an “Anim Notify” like so:

Animation Notifies in Unreal Engine | Unreal Engine 5.3 Documentation

Now the example above then uses BP to handle the notify, but it can also be done in C++. You need an AnimInstance C++ class which your actor uses and name it like “AnimNotify_YourNotifyNameInAllCaps”.

For example if you named the Notify to be “RELOADEND” in your animation:

void UCharacterAnimInstanceBase::AnimNotify_RELOADEND()
{
	this->Character->GetEquippedWeapon()->OnReloadEnd();
}

Thanks. But I don’t mean after an animation finished playing. I mean after the animation engine has evaluated all the bones and vertices on the skin is each frame.

For example: currently in my code the execution order is like:

frame 1:

my actor ticks, where I get my bone position.

then animation engine updates, where all the bones are placed.

then the skeleton is rendered on screen.

frame 2:

my actor ticks, where I get my bone position.

then animation engine updates, where all the bones are placed.

then the skeleton is rendered on screen.

See? The animation engine always updates the skeleton of the actor AFTER the tick of the actor. I’m always one frame late. What I got is not what is rendered on screen.

I need the opposite: get the bone position after animation engine update and before next frame.

I see what you mean, have no experience trying to solve this using the engine. I have however had a similair use case where I would cache the last/previous position and use it in the actor tick. This ofcourse means you have not any data on the very first frame.

That could be a potential solution. But it may not in sync with the rendering.

Thanks.

I’m very new to Unreal but I think you could either try a Post Process Animation Blueprint, or creating another tick function using the pre (or post) physics tick group.