Merge multiplayer_spawner and lobby-map into develop #3
@@ -22,9 +22,10 @@ func _input(event: InputEvent) -> void:
|
|||||||
|
|
||||||
|
|
||||||
@rpc("any_peer", "call_local", "reliable")
|
@rpc("any_peer", "call_local", "reliable")
|
||||||
func request_server_to_spawn_player(peer_id: int) -> void:
|
func request_server_to_spawn_player(peer_id: int, player_name: String) -> void:
|
||||||
var data: Dictionary = {}
|
var data: Dictionary = {}
|
||||||
|
|
||||||
data["peer_id"] = peer_id
|
data["peer_id"] = peer_id
|
||||||
|
data["player_name"] = player_name
|
||||||
|
|
||||||
player_spawner.spawn(data)
|
player_spawner.spawn(data)
|
||||||
|
|||||||
@@ -11,12 +11,13 @@ func spawn_player(data: Dictionary) -> Player:
|
|||||||
var new_player = player_scene.instantiate() as Player
|
var new_player = player_scene.instantiate() as Player
|
||||||
|
|
||||||
var peer_id = str(data["peer_id"])
|
var peer_id = str(data["peer_id"])
|
||||||
|
var player_name = str(data["player_name"])
|
||||||
|
|
||||||
new_player.set_multiplayer_authority(int(peer_id), true)
|
new_player.set_multiplayer_authority(int(peer_id), true)
|
||||||
new_player.set_player_name(peer_id)
|
new_player.set_player_name(peer_id, player_name)
|
||||||
new_player.position = Vector3.UP
|
new_player.position = Vector3.UP
|
||||||
|
|
||||||
GameManager.players.append(peer_id)
|
GameManager.players.append(int(peer_id))
|
||||||
|
|
||||||
return new_player
|
return new_player
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func _on_lobby_created(connect: int, this_lobby_id: int):
|
|||||||
print("[HOST] 3. Multiplayer host started (My Peer ID is always 1).")
|
print("[HOST] 3. Multiplayer host started (My Peer ID is always 1).")
|
||||||
|
|
||||||
#players.append(peer.get)
|
#players.append(peer.get)
|
||||||
GameManager.request_server_to_spawn_player.rpc_id(1, 1)
|
GameManager.request_server_to_spawn_player.rpc_id(1, 1, steam_username)
|
||||||
|
|
||||||
|
|
||||||
func join_lobby(this_lobby_id: int):
|
func join_lobby(this_lobby_id: int):
|
||||||
@@ -88,7 +88,7 @@ func _on_lobby_joined(this_lobby_id: int, _p, _l, response: int):
|
|||||||
func _on_connected_to_server():
|
func _on_connected_to_server():
|
||||||
print("[CLIENT] 4. Successfully connected to host's multiplayer peer.")
|
print("[CLIENT] 4. Successfully connected to host's multiplayer peer.")
|
||||||
print("[CLIENT] 5. Sending my info to the server for registration...")
|
print("[CLIENT] 5. Sending my info to the server for registration...")
|
||||||
GameManager.request_server_to_spawn_player.rpc_id(1, multiplayer.get_unique_id())
|
GameManager.request_server_to_spawn_player.rpc_id(1, multiplayer.get_unique_id(), steam_username)
|
||||||
|
|
||||||
|
|
||||||
func _on_p2p_session_request(steam_id_remote: int) -> void:
|
func _on_p2p_session_request(steam_id_remote: int) -> void:
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ func _ready():
|
|||||||
$Mesh.hide()
|
$Mesh.hide()
|
||||||
|
|
||||||
|
|
||||||
func set_player_name(player_name: String):
|
func set_player_name(peer_id: String, player_name: String):
|
||||||
name = player_name
|
name = peer_id
|
||||||
$Label3D.text = SteamManager.steam_username
|
$Label3D.text = player_name
|
||||||
|
|
||||||
|
|
||||||
#@rpc("any_peer", "call_local", "unreliable")
|
#@rpc("any_peer", "call_local", "unreliable")
|
||||||
|
|||||||
Reference in New Issue
Block a user