You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
398 B
20 lines
398 B
extends Node2D
|
|
class_name NpcFactory
|
|
|
|
@export var NPC_SCENE: PackedScene
|
|
@export var SPAWN_DELAY: float = 0.5
|
|
|
|
var current_spawn_duration = 0
|
|
|
|
func _ready():
|
|
if !NPC_SCENE:
|
|
push_error("npc scene is null")
|
|
|
|
func _physics_process(delta):
|
|
current_spawn_duration += delta
|
|
|
|
if current_spawn_duration > SPAWN_DELAY:
|
|
current_spawn_duration = 0
|
|
var npc = NPC_SCENE.instantiate()
|
|
|
|
add_child(npc)
|
|
|