Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FPS affects physics! #885

Closed
car1ot opened this issue Jun 2, 2020 · 8 comments
Closed

FPS affects physics! #885

car1ot opened this issue Jun 2, 2020 · 8 comments

Comments

@car1ot
Copy link

car1ot commented Jun 2, 2020

Hello. I have simulation (game plinko) - balls falling down from exact coordinates into baskets. Repeating the same simulation over and over, results are different!

Also, when I slow down time the simulation results become very different.

I made this issue, beause I need same results in multiple simulations using same exact fall coordinates.

@dclipca
Copy link

dclipca commented Jun 3, 2020

Indeed, I experience the same effect.

@car1ot
Copy link
Author

car1ot commented Jun 3, 2020

Indeed, I experience the same effect.

And what to do? I need the same results on server and client...

@wmike1987
Copy link

There's a PR all about timing inconsistencies. Regardless, you should fix your timestep to achieve determinism.

#777

@car1ot
Copy link
Author

car1ot commented Jun 9, 2020

There's a PR all about timing inconsistencies. Regardless, you should fix your timestep to achieve determinism.

#777

help pls, I quoted reply in #777

@liabru
Copy link
Owner

liabru commented Sep 12, 2020

Pretty much as @wmike1987 says (thanks!)

@DzzD
Copy link

DzzD commented Jan 25, 2021

I experience the same problem (wich sound to me logical unless you use fixed time step you IMHO cannot get same results specially with float computation), I fixed it by using fixed time (and integer) step (see below), this solution may be added as an option of the Engine.update ?

timeStep = 5;
...
...
lastFrameTime = frameTime;
frameTime =  Date.now();
let frameDuration = frameTime - lastFrameTime;`
let repeat= Math.floor(frameDuration/timeStep); 
let  remainingTime = frameDuration%timeStep;
frameTime -= remainingTime;
for(var n=0;n<repeat;n++)
{
   Matter.Engine.update(engine, timeStep);
}

@liabru
Copy link
Owner

liabru commented Jan 26, 2021

@DzzD good to know that approach is working for you, it's worth trying out branch #777 too if you get chance.

I've got similar prototypes of adaptive fixed timestep for Matter.Runner but none are yet production ready, it is something I'll prioritise though when I get back to #777.

@liabru
Copy link
Owner

liabru commented Nov 12, 2023

Closing this thread to refer to updates in #702 on this topic, thanks again for the reports here.

@liabru liabru closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants