From e6d21cbb8a9436f060bddef171dc2496667d3b2d Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 30 Aug 2021 17:45:40 +0200 Subject: [PATCH] Remove the nameplate if the entity gets controlled by the player and it wasn't before. --- game/player/Body.gd | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/game/player/Body.gd b/game/player/Body.gd index 6327b9ae..f4bc8b59 100644 --- a/game/player/Body.gd +++ b/game/player/Body.gd @@ -111,6 +111,8 @@ var just_place : bool = false var contact : RayCast = null +var _nameplate : Node = null + #var los : bool = false func _ready() -> void: @@ -769,6 +771,9 @@ func on_c_controlled_changed(val): _controlled = val if val: + if _nameplate: + _nameplate.queue_free() + var cam_scene : PackedScene = ResourceLoader.load("res://player/camera/CameraPivot.tscn") camera_pivot = cam_scene.instance() as Spatial add_child(camera_pivot) @@ -791,8 +796,8 @@ func on_c_controlled_changed(val): set_process_input(false) set_process_unhandled_input(false) var nameplatescn : PackedScene = ResourceLoader.load("res://ui/nameplates/NamePlate.tscn") - var nameplate = nameplatescn.instance() - add_child(nameplate) + _nameplate = nameplatescn.instance() + add_child(_nameplate)