parent
90500c2ee1
commit
478b5b9c60
@ -0,0 +1,20 @@ |
||||
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) |
||||
@ -0,0 +1,9 @@ |
||||
[gd_scene load_steps=3 format=3 uid="uid://b2hu7kxvxvgc1"] |
||||
|
||||
[ext_resource type="Script" path="res://nodes/npc_factory/npc_factory.gd" id="1_p5cuf"] |
||||
[ext_resource type="PackedScene" uid="uid://dvx48q5ecyxjs" path="res://nodes/npc/npc.tscn" id="2_exj6u"] |
||||
|
||||
[node name="npc_factory" type="Node2D"] |
||||
script = ExtResource("1_p5cuf") |
||||
NPC_SCENE = ExtResource("2_exj6u") |
||||
SPAWN_DELAY = 2.0 |
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue