Godotsteam: Update: Question about "Sending P2P packets

Created on 5 Apr 2020  路  8Comments  路  Source: Gramps/GodotSteam

Hello

We have looked at the FPS problem again. We have found that our reported error happens with the "Lobby" script.

#

func _process(delta):
# Run Steam callbacks
Steam.run_callbacks()
# Get packets
_read_P2P_Packet()

#

"_process" is executed as many times as you have FPS. So at 60 FPS the P2P packets are not executed fast enough, so we have the delays. At 144 FPS "_process" is executed more often, so there is no delay.

The problem now is that the game only runs at 60fps on notebooks, for example.

-Has anyone here an idea how to solve the problem?

We transmit "motion" all the time and execute move and slide for the puppet player. Is this maybe the wrong value?

-How do you transmit game movements to the other clients?

(If it's a big deal, I can pay for the effort).

Best Regards
Lukas

_Originally posted by @Luekuu in https://github.com/Gramps/GodotSteam/issues/125#issuecomment-609392990_

multiplayer question

Most helpful comment

Hello Gramps

We have found the solution for our network problem. (FPS dependency)

The "_read_P2P_Packet()" is now executed in a loop. So the whole thing runs without delay even at 20FPS.

func _process(delta):
    # Run Steam callbacks
    Steam.run_callbacks()
    # Get packets
    PACKET = Steam.getAvailableP2PPacketSize(0)
    for pack in PACKET:
        _read_P2P_Packet()

Thanks for the great job!
Best regards

All 8 comments

I am not expert about network but i think you have to learn about optimization about networking. "Optimization" and "Prediction" are the keywords here. But I am sorry i don't know about how to implement. You can get the simple idea from here maybe https://en.wikipedia.org/wiki/Client-side_prediction

Some other keywords for you:
network smoothing for games
network prediction for games
network optimization for game development

@alperc84 is correct, this is more of a network optimization thing. You will most likely have to do some research into the best ways to handle it. Client prediction is a good start.

You could probably post a code bounty somewhere, if you didn't want to figure it out. Also various gaming communities probably have a bunch of posts about this.

As this isn't actually an issue with the module, I will leave it open until next weekend then close it.

Thanks for your answer.

@Gramps
You have no experiences of your own? How to transmit a lot of trafic (player positions) via the P2P module.

And, yes, we need to look into that more deeply. :)

Regars, Lukas

@Luekuu I think I mentioned this the other issue, my networking experience is strictly limited to turn-based multiplayer so packet flow is never really an issue. I will be working on my Snackocalypse game again this summer which is a two-player bullet-hell game and will end up in the same position you are now. So hopefully by then you can give me advice!

Yeah, I know network optimization is a tricky task but there are a ton of resources and theories available.

Hello Gramps

We have found the solution for our network problem. (FPS dependency)

The "_read_P2P_Packet()" is now executed in a loop. So the whole thing runs without delay even at 20FPS.

func _process(delta):
    # Run Steam callbacks
    Steam.run_callbacks()
    # Get packets
    PACKET = Steam.getAvailableP2PPacketSize(0)
    for pack in PACKET:
        _read_P2P_Packet()

Thanks for the great job!
Best regards

That's a pretty novel solution. You got it working smoothly now?

Yes it all works also with 20fps. The movement delay is completely gone.

That's awesome. I'll have to make mention of this in the tutorials. Thanks for the update!

Was this page helpful?
0 / 5 - 0 ratings