How can i step physics and animations manually when lockstep is active?

Hi, I’m developing a multiplayer game and sometimes I need to roll back in time, and process inputs for each step until I get to the current step. how can I do this? is there a method on the engine or scene object for stepping physics and animations manually when lockstep is active?

Here’s what we do to animate when deterministic lockstep is used:

Basically, scene._animate() will make the regular animations run (ie. all animations but physics ones) and scene._advancePhysicsEngineStep will advance the physics animations.

2 Likes

Hello @Evgeni_Popov, I’m implementing a rollback networking model, and stepping manually this way works but there is an issue! physics animations and movements are deterministic because when I use scene._advancePhysicsEngineStep I can pass a time to it but there is no such thing for the scene._animate method and after rolling back to a specific step and stimulating to the current step the master frame of each animation group on each rollback step is different than the real step that was rendered before. is there a way to fix this? Here are some screenshots for a better understanding:

and this is my rollback logic:

This PR will allow you to pass a custom delta time to scene._animate:

4 Likes

Thank u so much @Evgeni_Popov. I think you need to change one more thing for animations to be fully deterministic. the Default frame time must be pass to scene._animate() on line 4467.

Also, I have a question! when can I get these new changes? I checked and there is no new release that includes this PR.

I agree but that would be a breaking change… I don’t know if we can consider it a bug or not.

cc @RaananW and @sebavan for their opinion.

The merged PRs are visible on the Playground the day after they are merged. New NPM packages are created each Thursday morning (EU time).

I was trying to think as well if it is a bug or not. My gut feeling is - it is a bug. Deterministic step should be deterministic. As long as we don’t change the else context I am fine with making this change, as it makes sense. If we want to be really safe here we can add a flag to the scene, but I think it will be hard to explain why we have a “isSceneDeterministicer” flag in the scene.

1 Like

I also think it’s a bug, here’s the PR:

2 Likes