finally add player name displaying
This commit is contained in:
@@ -33,7 +33,7 @@ func _enter_tree() -> void:
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_name_label.text = str(name)
|
||||
Networker.player_registered.connect(_on_networker_player_registered)
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
|
||||
@@ -90,6 +90,10 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
_handle_mouse_rotating(event as InputEventMouseMotion)
|
||||
|
||||
|
||||
func set_info(player_info: Dictionary) -> void:
|
||||
_name_label.text = player_info["name"]
|
||||
|
||||
|
||||
func _process_respawning() -> void:
|
||||
if global_position.y < _respawn_height:
|
||||
global_position = _respawn_point
|
||||
@@ -204,3 +208,9 @@ func _handle_mouse_rotating(event: InputEventMouseMotion) -> void:
|
||||
)
|
||||
)
|
||||
_camera.rotation.x = clamp(_camera.rotation.x, -PI / 2, PI / 2)
|
||||
|
||||
|
||||
func _on_networker_player_registered(peer_id: int, player_info: Dictionary) -> void:
|
||||
if peer_id != _peer_id:
|
||||
return
|
||||
set_info(player_info)
|
||||
|
||||
Reference in New Issue
Block a user