Stabelized survivor spawning.
This commit is contained in:
parent
0b47cc7b38
commit
a95eaa4dfb
2 changed files with 16 additions and 14 deletions
|
|
@ -12,17 +12,18 @@ var spawn_readiness: bool = false
|
||||||
@onready var start_pos = survivor_spawn.global_position
|
@onready var start_pos = survivor_spawn.global_position
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
spawn_readiness = false
|
start()
|
||||||
|
|
||||||
func _physics_process(delta):
|
func start() -> void:
|
||||||
if spawn_readiness == true:
|
|
||||||
spawn_survivor()
|
|
||||||
spawn_readiness = false
|
|
||||||
|
|
||||||
else:
|
|
||||||
await get_tree().create_timer(survivor_rate).timeout
|
|
||||||
spawn_readiness = true
|
spawn_readiness = true
|
||||||
|
spawn_survivor()
|
||||||
|
|
||||||
|
#func _physics_process(delta):
|
||||||
|
#if spawn_readiness == true:
|
||||||
|
#spawn_survivor()
|
||||||
|
#spawn_readiness = false
|
||||||
|
#
|
||||||
|
#else: pass
|
||||||
|
|
||||||
func spawn_survivor():
|
func spawn_survivor():
|
||||||
|
|
||||||
|
|
@ -31,12 +32,13 @@ func spawn_survivor():
|
||||||
else:
|
else:
|
||||||
|
|
||||||
var survivor_delay: float = randf_range(1, 2.5)
|
var survivor_delay: float = randf_range(1, 2.5)
|
||||||
var s = survivor.instantiate()
|
var start_variance = Vector3((randf_range(-1, 2)),0,0)
|
||||||
|
|
||||||
for x in range(survivors):
|
for x in range(survivors):
|
||||||
get_tree().root.add_child(s)
|
var s = survivor.instantiate()
|
||||||
|
get_tree().root.add_child.call_deferred(s)
|
||||||
#get_node("/root/Game/World").add_child(s)
|
#get_node("/root/Game/World").add_child(s)
|
||||||
s.position = start_pos
|
s.position = start_pos + start_variance
|
||||||
await get_tree().create_timer(survivor_rate * survivor_delay).timeout
|
await get_tree().create_timer(survivor_rate * survivor_delay).timeout
|
||||||
spawn_readiness = true
|
spawn_readiness = true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
extends CharacterBody3D
|
extends CharacterBody3D
|
||||||
|
|
||||||
var speed: int = 5
|
var speed: int = 3
|
||||||
var clumsiness: int = 0
|
var clumsiness: int = 0
|
||||||
|
|
||||||
@onready var safety_zone = get_node("/root/Game/World/ElevatorDoors/ElevatorSafeZone")
|
@onready var safety_zone = get_node("/root/Game/World/ElevatorDoors/ElevatorSafeZone")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue