Synchronize Animation Problem

Hello!
I’m trying to synchronize animations of two different TCastleScene objects. Like this:
animationName:= Body.CurrentAnimation.X3DName;
animationTime:= Body.CurrentAnimation.ElapsedTime;
Wear.SetTime(Body.Time);
Wear.AnimationTimeSensor(animationName).Start(True, True, animationTime);

But when I apply animation to a hidden object (Wear.Exists:= False;), the sync fault:

There is my test project:
sync_anim.zip (655.3 KB)

What am I doing wrong?

Thanks for the clear testcase + recording!

Confirmed, I can also reproduce the bug.

Hm, I tried some experiments now, but wasn’t yet able to really explain and/or solve it. On the first glance, you’re doing everything OK, we (in Castle Game Engine code) have some bug happening when one does PlayAnimation on a scene that has Exists = false. I thought that it’s easy to solve (PlayAnimation could call ApplyNewPlayingAnimation in some cases) but this didn’t help. I need to analyze it better to fix.

I’ll retry next week. Please ping me if I seem to forget and/or you need it urgently.

For today, I can offer a quick workaround: do not touch Wear.Exists, instead only modify Wear.Visible. That is, let “Undress” do Wear.Visible:=false, let “Dress” start with Wear.Visible:=true. Possibly this also does what you need, and it definitely avoids the problem.

Thanks for answer. I will use .Visible parameter for now.