22 lines
559 B
GDScript
22 lines
559 B
GDScript
extends Sprite2D
|
|
class_name Threat
|
|
|
|
@export var node: Node2D
|
|
@onready var line: Line2D = $line
|
|
@onready var animations: AnimationPlayer = $animations
|
|
|
|
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
|
|
line.points[0] = -position
|
|
|
|
func declare_danger():
|
|
animations.play("blink")
|
|
func release_danger():
|
|
animations.stop()
|
|
visible = true
|