First of all, I apologize to everyone for my poor English.
I'm experiencing serious lag issues in my multiplayer game, which uses the Construct 3 Multiplayer Plugin with peer-to-peer (P2P) architecture. The game is similar to Haxball, where the synchronization needs to be precise to keep the gameplay fluid. However, players are reporting that the lag is making the game almost unplayable, even in situations where latency should be acceptable.
Currently, the plugin's default clientDelay is 80ms, but I've noticed that this value causes noticeable delay in inputs and object synchronization. I've made a few changes to try to solve the problem:
- I reduced the clientDelay to 20ms. This has brought some improvement, but the lag still persists, especially on networks with an average ping above 50ms.
- I also increased the packets per second (pps) rate from 30pps to 24pps, which helped reduce data traffic, but had minimal impact on lag.
- I considered increasing it to 60pps. However, since the game is running relatively well at 24pps, I believe the problem may be more related to state extrapolation and correction than just the sending frequency.
In my game, I only sync the following information:
- Players: Position, skin, pass state (0-1), shot state (0-1), velX and velY (ranging from -220 to 220).
- Ball: Position only.
- Game status (propsmatch): Game control information (pretty much static).
Still, the lag doesn't decrease to a playable level. Ideally, the delay between player action and game response should be between 30-80ms, but I can't achieve this consistently.
Another serious issue I'm facing is object persistence when switching rooms. When a player leaves a room and enters another, the objects are not reset correctly. This causes:
The settings from the last room to remain active.
Objects to get "stuck" in their old states, which affects the new game.
For example:
- Synchronized players and objects do not appear (they become invisible)
Apparently, the layout is not resetting as it should, and this has become a critical issue for maintaining a consistent experience.
I'm open to suggestions on how to tweak the plugin's parameters or even modify the initialization logic to fix the issues. If games like Haxball can handle lag and maintain a playable experience, I believe I can achieve a similar result in my project as well.