I’m using Playables to play animations, using a LayerMixer to mix together two layers.
These animations are locked to 12 fps, so it’s important that the animations on the two layers stay in sync (modulo 1/12), as otherwise the base layer animation would update at different times than the override layer on top of it.
The way I’m trying to do this is something that seems to me like it’d be pretty straightforwards. When I start playing a playable on the override layer, I set it’s time to the time of the base layer, modulo the framerate:
var layer0PlayableTime = layer0Playable.GetTime();
var offset = layer0PlayableTime % (1f / 12f);
layer1Playable.SetTime(offset);
This runs into a pretty bad problem, though! As noted by @Kybernetik here, the next frame after you do SetTime, the playable will not increment it’s time. So on the frame I update the animation, the layers are in sync, but on the next frame they desync by exactly one frame.
I don’t quite know how I’d work around this - I can’t offset the layer 1 frame by the required time, as I don’t know the framerate in the future. I can’t compensate on the next frame by manually incrementing the time, as SetTime is the problem in the first place. I could blindly make the assumption that a) vsync is on and b) I’m not dropping a frame, and then offset the time by deltaTime, but those are silly assumptions to make.
Any advice?