godot-psd-training/sceen/Area3D/DEntranceAreaDetection.gd

19 lines
579 B
GDScript3
Raw Normal View History

extends Area3D
var peopleAtDEntrances: Array[PlayerPathFollow] = []
func _ready():
self.connect("area_entered",Callable(self,"_on_area_entered"))
self.connect("area_exited",Callable(self,"_on_area_exited"))
func _on_area_entered(area: Area3D) -> void:
var peopleWalkFollow = area.get_parent().get_parent()
if peopleWalkFollow is PlayerPathFollow :
peopleAtDEntrances.append(peopleWalkFollow)
func _on_area_exited(area: Area3D) -> void:
var peopleWalkFollow = area.get_parent().get_parent()
if peopleWalkFollow is PlayerPathFollow :
peopleAtDEntrances.remove_at(0)