RetekEger

Deterministic lockstep issue with high FPS

Recommended Posts

Hi,

I'm pretty new to Babylon.js, only started using it a few days ago, but really enjoy it, great work! :)

I encountered some odd behavior with using deterministic lockstep on my setup, when running the example from the Animation page (https://www.babylonjs-playground.com/index.html#DU4FPJ#3) on my laptop's display (120Hz) the animation is twice as fast as on my connected monitor (60Hz) - tried with both Latest and Stable version, with both Cannon and Oimo plugins. My first guess would be that the algorithm is only prepared to handle low FPS, and does not take into account possible higher values. Also tried to dig in to the project on GitHub, but since I'm not that familiar with the structure, sadly I did not find the sources responsible for the behavior. Could some expert please verify my finding?

Thank you, keep up the good work, cheers!

Share this post


Link to post
Share on other sites

Hi @RetekEger,

your guess is right. The default values are set for 60fps. You can see the get and setTimeStep functionis of both engines. You can set the timestep to be different and fit your needs:

physicsEngine.setTimeStep(1/120)

I hope this gets you further!

 

Share this post


Link to post
Share on other sites

Hi @RaananW,
Thanks for the fast answer! Actually in the before mentioned example, the timestep is explicitly set to 1/60, and for my scenario I find 120 FPS a bit of overkill for this edge case, although I'd need to be sure, that animation speed is independent of the user's FPS. Is there a best practice, to limit the physics engines' FPS to 60, even if running on a 120Hz monitor? I'd expect all animations to play the same speed if I use deterministicLockstep, regardless the environment (except for lockstepMaxSteps), but might be, that I'm misunderstanding the whole concept - that is why I asked for confirmation.

Thanks in advance!

Share this post


Link to post
Share on other sites

Yep, you are totally right - it should still run at 60FPS even on a 120FPS monitor.

Just for me to be sure - when you say animations, you mean the physical movement of objects, right? Babylon also have an animations API, both are implemented in the deterministic step.

 

maybe would be better to have a playground for this, I will try to emulate this on my poor 60fps screen :)

Share this post


Link to post
Share on other sites

I just went and confirmed, that the issue only exists with the physics engines' time-step, not with programmatic or loaded skeletal animations.

Playground tutorial where the issue can be seen, also can change to Oimo on line 11 with same output:
https://www.babylonjs-playground.com/#DU4FPJ#3

Confirmation control animation that I checked:
https://www.babylonjs-playground.com/#IQN716#9

If I can help with anything to move the solution further just ping me! :) Thx!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.