Added client nameplates

This commit is contained in:
Layla 2020-05-02 16:36:51 -04:00
parent 948b379f9d
commit ee233c52f0
No known key found for this signature in database
GPG Key ID: A494D9357BA1BE31
3 changed files with 9 additions and 2 deletions

View File

@ -3,8 +3,12 @@ extends KinematicBody2D
export var user : String = ""
func _ready():
set_username("")
func set_username(username):
print(username)
user = username
$Label.text = user
#$Label.text = $"/root/NetworkManager".username
func _process(delta):
var movePos : Vector2 = Vector2(0,0)

View File

@ -34,7 +34,8 @@ func _init():
client.bind()
func connect_to_server():
if peer:
peer.disconnect_now()
server_address.set_host(server_host)
server_address.set_port(SERVER_PORT)
peer = client.host_connect(server_address)

View File

@ -50,6 +50,8 @@ func update_entity(entity_id : String, pos : Vector2, type : String):
display_error("Trying to load entity of type: " + type + ", but failed.")
if entity:
entity.position = pos
if entity.has_method("set_username"):
entity.set_username(entity_id)
func delete_entity(entity_id : String, type : String):
var entity : Node2D = get_node_or_null( str(type + "-" + entity_id))