21 lines
481 B
GDScript
21 lines
481 B
GDScript
extends Sprite2D
|
|
class_name Threat
|
|
|
|
@export var node: Node2D
|
|
|
|
const dst: float = 70.0
|
|
|
|
func _physics_process(_delta: float) -> void:
|
|
if (node.global_position - get_parent().global_position).length() < dst:
|
|
modulate.a = 0
|
|
else:
|
|
position = dst * (node.global_position - get_parent().global_position).normalized()
|
|
modulate.a = 1
|
|
|
|
func declare_danger():
|
|
print("danger")
|
|
$animations.play("blink")
|
|
func release_danger():
|
|
print("no danger")
|
|
$animations.stop()
|
|
visible = true
|