Added client nameplates
This commit is contained in:
parent
948b379f9d
commit
ee233c52f0
@ -3,8 +3,12 @@ extends KinematicBody2D
|
|||||||
export var user : String = ""
|
export var user : String = ""
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
set_username("")
|
||||||
|
|
||||||
|
func set_username(username):
|
||||||
|
print(username)
|
||||||
|
user = username
|
||||||
$Label.text = user
|
$Label.text = user
|
||||||
#$Label.text = $"/root/NetworkManager".username
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
var movePos : Vector2 = Vector2(0,0)
|
var movePos : Vector2 = Vector2(0,0)
|
||||||
|
@ -34,7 +34,8 @@ func _init():
|
|||||||
client.bind()
|
client.bind()
|
||||||
|
|
||||||
func connect_to_server():
|
func connect_to_server():
|
||||||
|
if peer:
|
||||||
|
peer.disconnect_now()
|
||||||
server_address.set_host(server_host)
|
server_address.set_host(server_host)
|
||||||
server_address.set_port(SERVER_PORT)
|
server_address.set_port(SERVER_PORT)
|
||||||
peer = client.host_connect(server_address)
|
peer = client.host_connect(server_address)
|
||||||
|
@ -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.")
|
display_error("Trying to load entity of type: " + type + ", but failed.")
|
||||||
if entity:
|
if entity:
|
||||||
entity.position = pos
|
entity.position = pos
|
||||||
|
if entity.has_method("set_username"):
|
||||||
|
entity.set_username(entity_id)
|
||||||
|
|
||||||
func delete_entity(entity_id : String, type : String):
|
func delete_entity(entity_id : String, type : String):
|
||||||
var entity : Node2D = get_node_or_null( str(type + "-" + entity_id))
|
var entity : Node2D = get_node_or_null( str(type + "-" + entity_id))
|
||||||
|
Reference in New Issue
Block a user