22 lines
609 B
GDScript
22 lines
609 B
GDScript
extends TextureRect
|
|
|
|
var current_target : Node3D
|
|
var current_camera : Camera3D
|
|
|
|
func _ready() -> void:
|
|
HudSignalBus.current_camera_changed.connect(set_current_camera)
|
|
current_camera = HudSignalBus.current_camera
|
|
HudSignalBus.new_weapon_target.connect(set_current_target)
|
|
|
|
func set_current_camera(value):
|
|
current_camera = value
|
|
|
|
func set_current_target(value):
|
|
current_target = value
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
if is_instance_valid(current_target):
|
|
position = current_camera.unproject_position(current_target.global_position)-Vector2(32,32)
|
|
else:
|
|
position = Vector2(-300,-300)
|