My version of spawning…spawns too many survivors!
This commit is contained in:
parent
ecd79e66e3
commit
0b47cc7b38
8 changed files with 91 additions and 17 deletions
42
scenes/component_spawn.gd
Normal file
42
scenes/component_spawn.gd
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
extends Node3D
|
||||
|
||||
var survivors: int = 5
|
||||
var survivor_rate: float = .75
|
||||
var speed_modifer: int = 0
|
||||
var spawn_readiness: bool = false
|
||||
|
||||
@onready var survivor = preload("res://scenes/survivor.tscn")
|
||||
@onready var world = preload("res://scenes/world.tscn")
|
||||
|
||||
@onready var survivor_spawn = get_node("/root/Game/World/SuvivorSpawn")
|
||||
@onready var start_pos = survivor_spawn.global_position
|
||||
|
||||
func _ready() -> void:
|
||||
spawn_readiness = false
|
||||
|
||||
func _physics_process(delta):
|
||||
if spawn_readiness == true:
|
||||
spawn_survivor()
|
||||
spawn_readiness = false
|
||||
|
||||
else:
|
||||
await get_tree().create_timer(survivor_rate).timeout
|
||||
spawn_readiness = true
|
||||
|
||||
|
||||
func spawn_survivor():
|
||||
|
||||
if spawn_readiness == false: pass
|
||||
|
||||
else:
|
||||
|
||||
var survivor_delay: float = randf_range(1, 2.5)
|
||||
var s = survivor.instantiate()
|
||||
|
||||
for x in range(survivors):
|
||||
get_tree().root.add_child(s)
|
||||
#get_node("/root/Game/World").add_child(s)
|
||||
s.position = start_pos
|
||||
await get_tree().create_timer(survivor_rate * survivor_delay).timeout
|
||||
spawn_readiness = true
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue