Hi! Is there any difference in setting game object position via go.set_position and dmGameObject::SetPosition ?
I’m trying to implement root motion for animated 3d mesh in a native extension and noticed some kind of jitter on object moved by C function when camera moves…
No difference:
int Script_SetPosition(lua_State* L)
{
Instance* instance = ResolveInstance(L, 2);
dmVMath::Vector3* v = dmScript::CheckVector3(L, 1);
dmGameObject::SetPosition(instance, dmVMath::Point3(*v));
return 0;
}
The question is, is something else affecting the object? You’re mentioning “animated”. Are you doing the animation in Lua or C++?
Does it have physics?
Output the difference in position, and see if it changes more during a frame. Otherwise, is it perhaps the camera’s movement that’s strange?
Hmm… No physics, position is updated once in 2 frames. Skeleton animation is performed in shader, root motion is calculated in C (I remove transforms from root bone matrix before sending data to shader).
no root motion:
root motion:
As a solution I can use root motion only for turns and do script motion for straight walking… But I spent so many efforts to make RM work…
The difference is: script motion moves character every frame, root motion -only if pose changes (30fps animation, so it’s once in 2 frames). Setting Update Frequency to 30 makes it look correct.
But is there any way to fix it at 60 fps ?
Don’t you need to interpolate your 30 fps animation to the game framerate to avoid visual jittering? Which might not be a stable 60 fps, but 120, 144 or not stable at all, etc.
1 Like
Yep, probably. I’m new to this approach, will research it.