So, I’m developing a multiplayer game, where I use physicsHelper. And depends on the laptop people have different behaviors. Yes, I know, it is fanny. If you want to win, then buy new laptop. It is a joke. How I can control it and make only one behavior?
haha. It’s not a joke for apple. I’m sure if you ask’em, they would give you this as the only solution
I didn’t dig into it and I’m not the best with havok physics either but I noticed you are using a time out here or there. May be you should check on the frameRate?
For multiplayer games or simulations where consistent timing and physics are important, deterministic lockstep is often the answer.
Have you tried enabling that in the engine? That will force physics computations to occur at the same intervals no matter the frame rate (within reason, ofc)
Yeah, well I’m not sure about havok using this method. There’s nothing about it in the doc and I’m afraid I’m not qualified. Now just who is the havok physics guru in the forum? May be try cc @Cedric…
As I see it, it is not Havok, but an Engine plugin.
Stack
in node_modules/@babylonjs/core/Engines/thinEngine.js:4777 we have a class ThinEngine
In this class QueueNewFrame return requestAnimationFrame. So on a Macbook monitor, it is 120fps, in external 60fps.
runRenderLoop() use requestAnimationFrame() for _renderLoop
Ok. Good. Let’s see on Engine.
class Engine extends ThinEngine and has _renderLoop too (redefine)
And for registering the next frame, use _queueNewFrame from class ThinEngine where return requestAnimationFrame
in the line:
this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow());
Instead requestAnimationFrame for physic, I found customAnimationFrameRequester
Hey, I don’t know what is your multiplayer architecture but I’d guess that for the multiplayer physics you usually have authoritative server which sends the ‘truth’ to the clients and the clients are only rendering what server is sending them?
No, I use WebRTC, peer-to-peer between browsers. Without a central server. Just sharing coordinates. But it is not important. I make this project only for fun, because I want to learn about Babylon
Question more, why does physics depend on fps And how synchronize behavior
At the moment I am experimenting with:
Set requestAnimationFrame and make the limit with 60fps everywhere
Changing physicsEngine.setTimeStep() depend of value from engine.getFps()
I didn’t find any solutions, so I make experiments