PacktPublishing / The-Essential-Guide-to-Creating-Multiplayer-Games-with-Godot-4.0

The Essential Guide to Creating Multiplayer Games with Godot-4.0 published by Packt
MIT License
73 stars 28 forks source link

Error with Multiple instances #5

Open LocoUnPocoNadaMas opened 4 months ago

LocoUnPocoNadaMas commented 4 months ago

image Tested with 3 instances (server ok, player1 ok, the 2nd player has many errors). But it's playable...

henriiquecampos commented 3 months ago

Some times we get these errors while the game is trying to set up the connection. Could you try to use the approach below to connect with server?

func _ready():
    if not multiplayer.is_server():
        var server_connection = multiplayer.multiplayer_peer.get_peer(1)
        var latency = server_connection.get_statistic(ENetPacketPeer.PEER_ROUND_TRIP_TIME) / (1000 * 2)
        await get_tree().create_timer(latency).timeout
        rpc_id(1, "sync_world")
        rpc_id(1, "create_spaceship")

Also, if there are errors but the game still runs with all its features working, it might have to do with Godot's internal workings, so maybe on future patches these get fixed