extends Node3D @export var rat : Resource @onready var ray = $RayCast3D @onready var area_3d = $Area3D # Called when the node enters the scene tree for the first time. func _ready(): pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): pass func spawn_rat(end_hole,control_node): var spawn_rat = rat.instantiate() spawn_rat.position = ray.global_position spawn_rat.transform.basis = ray.global_transform.basis spawn_rat.look_at_from_position(end_hole.position,Vector3.UP) spawn_rat.end_hole = end_hole get_tree().get_root().add_child(spawn_rat) func _on_area_3d_body_entered(body): if body.is_in_group("rat"): if body.end_hole == self: #body.control_node.spawn_amount += 1 #signal to control node that another rat can enter the scene body.queue_free()