Godot Version
4.4.1
Question
Hey guys,
Im using the GodotSteam Multiplayer Peer
Do you know why the client thinks its of authority 1.
The host doesnt think that the client is of auth 1 but the client does
and is_multiplayer_authority returns false
This is the main code.
Its supposed to connect players and to bring them to a lobby screen.
extends Node3D
@onready var lobby_id_input: LineEdit = %LobbyIDInput
@onready var join_btn: Button = %JoinBtn
@onready var main_menu: Control = %MainMenu
@onready var ms: MultiplayerSpawner = $MultiplayerSpawner
var lobby_id: int
var peer = SteamMultiplayerPeer.new()
func _ready() -> void:
main_menu.show()
# Steam Signals
Steam.lobby_joined.connect(_on_lobby_joined)
Steam.lobby_created.connect(_on_lobby_created)
ms.spawn_function = spawn_func
print("Steam ID: " + str(Steam.current_steam_id))
Global.user_id = Steam.current_steam_id
##----------------------------------------------------------------------------------------------
## UI Handlers
##----------------------------------------------------------------------------------------------
func _on_host_button_down() -> void:
Steam.createLobby(Steam.LOBBY_TYPE_PUBLIC)
func _on_button_client_down() -> void:
Steam.joinLobby(int(lobby_id))
func _on_lobby_id_input_text_changed(new_text: String) -> void:
lobby_id = int(new_text)
if new_text != "":
join_btn.disabled = false
else:
join_btn.disabled = true
##----------------------------------------------------------------------------------------------
## Steam Callbacks
##----------------------------------------------------------------------------------------------
func _on_lobby_created(_success: bool, _lobby_id: int) -> void:
if not _success:
print("Lobby was unfortunately not created")
return
lobby_id = _lobby_id
Global.lobby_id = lobby_id
setup_host()
print("Lobby created! ID: ", _lobby_id)
func _on_lobby_joined(_lobby_id: int, _permissions: int, _locked: bool, response: int) -> void:
if response != Steam.CHAT_ROOM_ENTER_RESPONSE_SUCCESS:
print("Failed to join lobby!")
return
lobby_id = _lobby_id
Global.host_id = Steam.getLobbyOwner(lobby_id)
Global.lobby_id = lobby_id
setup_steam_lobby()
var owner_id = Steam.getLobbyOwner(_lobby_id)
if owner_id == Steam.getSteamID():
ms.spawn("uid://d1fgju416iq24") # Lobby UID
print("I am the host, lobby joined")
else:
setup_client(owner_id)
print("Client connected to host:", owner_id)
func _on_peer_connected(id: int) -> void:
print("New client connected! Peer ID: ", id)
##----------------------------------------------------------------------------------------------
## Helper Functions
##----------------------------------------------------------------------------------------------
func setup_steam_lobby():
Steam.setLobbyJoinable(lobby_id, true)
Steam.setLobbyData(lobby_id, "name", Steam.getPersonaName() + "`s Lobby")
func setup_client(owner_id):
peer.create_client(owner_id, 0) # virtual port = 0
multiplayer.multiplayer_peer = peer
func setup_host():
peer.create_host(0)
multiplayer.multiplayer_peer = peer
multiplayer.peer_connected.connect(_on_peer_connected)
func spawn_func(data):
main_menu.hide()
return (load(data) as PackedScene).instantiate()
Thank you!