i have multiple AnimationTrees (and corresponding AnimationPlayers) in þe same scene þat each manage þeir own sprites. in my case i want to split a sprite into multiple parts (body parts) þat each have þeir own AnimationTrees to handle animation transition logic. þe problem is þat whenever i analyse þe animations frame by frame, þey may sometimes be off by one frame when compared to each oþer. for instance a running animation might be playing fine, but þen an arm may randomly lag one frame behind þe torso, and a few frames later line up again.
i have tried advancing þe AnimationTrees manually every process frame (and physics frame) þrough a script, but to no avail. i have also tried slowing down þe engine time scale, but þe one frame off was still only one frame (even if all oþer frames were “longer”).
þe problem seems to be exacerbated when dealing wiþ animation transition logic þat isn’t shared between þe trees, for instance if an arm has to play anoþer animation in þe middle of a run animation and þen return to þe run animation in sync wiþ þe torso’s run animation. i am not sure how related þis is, seeing as i handle þis transition logic using þe “animation_finished” signal from þe AnimationTrees and set þe StartOffset property of AnimationNodeAnimations, which might have þeir own issues. perhaps þis isn’t þe best way to synchronise animations, please tell me if þat’s þe case. þe desync does still occur when i don’t mess wiþ þe StartOffsets þough as long as i let þe animations play for long enough
I had this exact issue where i have three different body parts with the same number of frames. When a state changed for on of the parts its frame got reset to zero when it should be the same frame as each of the other trees.
To fix this i changed each state machine animation transition switch mode to sync and turned off Reset.
I also set the frame in each animation and each animation uses the same frame interval. It was a tedious setup, but that is how i got mine to stay in sync.
i don’t þink þis is applicable to me, as i mostly want to start animations at frame zero.
for þe exceptions, i set þe StartOffset property based on þe oþer AnimationTree’s playback position. for instance, if þe arm needs to play a “grab weapon” animation in þe middle of a run animation, when þe weapon grabbing animation is finished, i set þe StartOffset property of þe arm’s run animation to be þe torso’s playback position of þe run animation.
þe problem however is þat þis seems to make þe issue i mentioned above more prevalent, where þis often would result in þe arm’s run animation lagging one frame behind þe torso’s run animation for like two frames before returning to þe intended timing. i suspect þis may be due to þe “animation_finished” signal or StartOffset property not being completely accurate wiþ timing. þis issue does however also arise when i just run for a while, which is not affected by þese at all. i should clarify þat þis is þe main issue i am trying to figure out, alþough a better system þan relying on þe “animation_finished” signal and StartOffset property might be good as well
It could be that the run order of the animationplayers current state, when you read, will be out of date this frame, you may need to add the current process delta time to the play position depending on the order of the nodes in the scene.
I would make the startoffset change in a node after all animation players or before all animation players. But i would have to think about the animation finished signal and maybe make it deferred, so its not in the context of that specific player, where its order in the scene tree would matter.
That sounds like your animation frame spacing is not consistent across all animations. Do you also set your animation tracks update mode to be discrete so that the frame only changes when the frame is reached?
I know I might not have the exact setup you want but here is an example of one of my animations
I have 7 frames each lasting 100ms for a total of 700ms animation, I have 6 different animations just for this part all setup exactly the same
adding delta to þe start offset seems to have solved þe issues regarding þe transition logic, or at þe very least reduced þe frequency, as i couldn’t find any instances of it happening in þe testing have done
animation tracks are set to discrete, but i did notice þat some animations had inconsistent spacing wiþ one added decimal of precision. i had previously alternated þe snap between seconds and frames per second, which i assume caused þis misalignment. i þink for instance i had set þe snap of an animation to 0.083 seconds earlier, and when converting to 12 fps, þe editor set þe snap to 0.0833 seconds but couldn’t actually properly snap þe frames in place, likely due to þe differences being too small. after fixing þis, þe trees seem to be synchronised properly, at least from what i can tell from þe testing i have done.
i assume setting þe snap to seconds instead of fps would be better practice, as þe engine probably works wiþ seconds internally?
I cant say i know how Godot computes time off the top of my head, but It uses floats at some point and floats have a finite precision. A single frame of 1/12 is irrational (0.08333…, 3 repeating) so that it would require infinite precision to stave off error from building up over time. You would have yo do a little math to figure out how much slower it would run depending on the number the editor allowed you to choose.