expressobits / steam-multiplayer-peer

Steam Sockets Multiplayer Peer for Godot 4 via GDExtension
MIT License
199 stars 13 forks source link

Game closes on peer.create_host() and no errors are shown in logs #19

Open Myle21 opened 4 months ago

Myle21 commented 4 months ago

the os is windows 10 x64, godot version is 4.2.2 and the steam is in fact intializing correctly and is doing so before the multiplayer peer. here's the only place in code that uses SteamMultiplayerPeer:


func create_lobby(lobby_type = Steam.LOBBY_TYPE_PUBLIC, lobby_max_members = 16) -> void:
    if lobby_id == 0:
        Steam.createLobby(lobby_type, lobby_max_members)

func _on_lobby_created(connect: int, this_lobby_id: int) -> void:
    if connect == 1:
        lobby_id = this_lobby_id
        print("Created a lobby: %s" % lobby_id)

        Steam.setLobbyJoinable(lobby_id, true)

        var set_relay: bool = Steam.allowP2PPacketRelay(true)

        print("Allowing Steam to be relay backup: %s" % set_relay)

        create_lobby()
        peer = SteamMultiplayerPeer.new()
        var err = peer.create_host(0,[])
        multiplayer.multiplayer_peer = peer
KiroTheBlueFox commented 3 months ago

Got the same issue with Godot 4.3 Beta 3

arnaudvergnet commented 4 weeks ago

Hey, I had the same issue while using GodotSteam and this addon but it was because I was creating both the host and the client at the same time.

When you create a lobby, both lobby_created and lobby_joined signals are fired. So if you create the client in the callback to lobby_joined, make sure to check if you are not the host by using Steam.getLobbyOwner(lobby_id)

Check out this example, it helped a lot https://github.com/MichaelMacha/SteamMultiplayerPeerExample/blob/demo/gamestate.gd