19 lines
529 B
GDScript
19 lines
529 B
GDScript
extends Node3D
|
|
class_name RatHole
|
|
|
|
@export var rat : Resource
|
|
@onready var spawnpos: Marker3D = $spawnpos
|
|
@onready var area_3d = $Area3D
|
|
|
|
func spawn_rat(end_hole):
|
|
var spawn_rat = rat.instantiate()
|
|
spawn_rat.position = spawnpos.global_position
|
|
spawn_rat.end_hole = end_hole
|
|
get_parent().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()
|