19 lines
435 B
GDScript3
19 lines
435 B
GDScript3
|
extends Node2D
|
||
|
|
||
|
@export var spawned_entity: PackedScene
|
||
|
@export var active: bool = false
|
||
|
@export var spawn_time: float = 1.0
|
||
|
|
||
|
var spawn_timer: float = 0.0
|
||
|
|
||
|
func _process(delta: float) -> void:
|
||
|
if !active:
|
||
|
return
|
||
|
spawn_timer += delta
|
||
|
if spawn_timer >= spawn_time:
|
||
|
spawn_timer -= spawn_time
|
||
|
var entity: Node = spawned_entity.instantiate()
|
||
|
add_sibling(entity)
|
||
|
if entity is Node2D:
|
||
|
entity.global_position = global_position
|