Others get lag while playing my multiplayer game with me, but I don't

Greetings!

I created a multiplayer game that I’ve been working on for a few weeks now. My primary way of playtesting was with opening multiple game instances, that’s how I looked for and eliminated bugs and how I developed the game.
I’m satisfied with how it works, as intended and smoothly with around 2 - 2.5 ms showing in the performance profiler, in the base game.

Before sharing the game publicly, I wanted to playtest it with a friend, but what happened is that his game instance was running incredibly slowly, even on the intro scene that had an extremely low amount of events - It moved at 45 FPS there (in contrast to my 60 FPS on my PC). It dropped even lower for him when the gameplay started, and he’s got a gaming computer.

I’m at a loss here, and I have no idea how to solve this problem, the game is unplayable with a problem like this. I don’t know where to start looking and, after investing so much time into this game, I just want to get rid of this problem.

If anyone has any idea why this happens, please let me know.

Thanks in advance.

Can you screen snip the events for you, and event for the other players if they are different?

1 Like

There are large amounts of events from the gameplay that differ from Host to other Players. Screenshotting and sending them all would be difficult considering the project size, but more importantly - I don’t understand how the multiplayer behaviour could be the cause of the problem here because the FPS is lowered on my friend’s PC in the intro scene. (by intro scene I’m referring to the scene that says “Created by…” right when you open the game.) That scene comes before we even connect to the lobby.

Not only that, he tried to be the host of the lobby to see if that fixes things, but it didn’t, it just came with its own bugs, for both of us.

I think what happens here is, because GDevelop is frame-based, his and my PC communicate at different framerates, which means our PCs receive and send multiplayer info at different times, mine at 60 FPS and his at lower. That would explain why everything works perfectly when I run two instances on my PC myself - because my instances run at 60 FPS and it doesn’t change.

What do you think about this?

You have an FPS counter on the intro scene?

Have you checked the task manager to see what’s hogging the CPU?

You wrote he’s got a gaming machine that runs at a lower refresh rate than your device? If the slower machine has slower gameplay, then it could be because updates are done at a fixed amount and could be resolved with a TimeDelta().

If you've not aware or sure on how to use TimeDelta(), expand this for a brief explanation:

Say, for example, you are moving an object by 5 pixels every time. At 60FPS it’ll move 300 pixels per second because the 5 pixels increment is run every frame (60 * 5). But at 40FPS, it only moves 200 pixels per second (40 * 5).

TimeDelta() is a function that returns the number of seconds that has passed since the last game frame. At 60 FPS, it’s around 1/60 (0.01667). At 40 FPS is around 1/40 (0.025).

To use it, decide how many pixels you want the object to move in a second, and multiply this by TimeDelta(). So your expression will be something like “Update X position add 300 * TimeDelta()”.

This means for the 60 FPS machine will add 5 pixels at a time (300 * 1/60). But the 40 FPS machine will add 7.5 pixels each time (300 * 1/40). After a second the object has moved 300 pixels on both machines.

1 Like

Yes, I put an FPS counter on the intro and main menu scene. My instance shows 60 everywhere and his around 45, slowed for some reason.

Here’s a screenshot of his Task manager while the game is running on gd.games:

The main menu scene doesn’t have much events, and the intro scene before this has even less.
The performance profiler shows around 0.7ms in this main menu scene on the image.

The TimeDelta() feature sounds neat and useful generally to not create additional bugs when framerates are different, however, even if I did implement it, I wouldn’t want the people playing to have the experience ruined because of this bad framerate.

Again, I have no idea why this happens, but I’m suspecting it’s got something to do either with GDevelop itself or the gd.games website.

If you’d like and if you have time, I could share the gd.games link and you could try it yourself.

But that’s what TimeDelta() fixes - so everyone has the same experience regardless of frame rate (unless it’s really, really bad).

Go for it.