22 lines
473 B
GDScript3
22 lines
473 B
GDScript3
|
extends Area2D
|
||
|
|
||
|
class_name ActivationRange
|
||
|
|
||
|
signal player_entered()
|
||
|
signal player_left()
|
||
|
|
||
|
func _ready():
|
||
|
connect("body_entered", self, "_body_entered")
|
||
|
connect("body_exited", self, "_body_left")
|
||
|
|
||
|
func in_range():
|
||
|
return overlaps_body($"/root/scene/world".player)
|
||
|
|
||
|
func _body_entered(body: Node):
|
||
|
if body == $"/root/scene/world".player:
|
||
|
emit_signal("player_entered")
|
||
|
|
||
|
func _body_left(body: Node):
|
||
|
if body == $"/root/scene/world".player:
|
||
|
emit_signal("player_left")
|