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
|
||||||
|
|
||||||
1
scenes/component_spawn.gd.uid
Normal file
1
scenes/component_spawn.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dr7xg7ly6q13g
|
||||||
10
scenes/component_spawn.tscn
Normal file
10
scenes/component_spawn.tscn
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
[gd_scene format=3 uid="uid://bb0o3ov6u308v"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://dr7xg7ly6q13g" path="res://scenes/component_spawn.gd" id="1_wr5sp"]
|
||||||
|
|
||||||
|
[node name="Component Spawn" type="Node3D" unique_id=649225939]
|
||||||
|
script = ExtResource("1_wr5sp")
|
||||||
|
|
||||||
|
[node name="SpawnMarker" type="Marker3D" parent="." unique_id=1293702318]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
gizmo_extents = 1.15
|
||||||
6
scenes/game.gd
Normal file
6
scenes/game.gd
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
extends Node3D
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
$ComponentSpawn.spawn_survivor()
|
||||||
|
|
||||||
|
|
||||||
1
scenes/game.gd.uid
Normal file
1
scenes/game.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bo7jao24qe2o7
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
[gd_scene format=3 uid="uid://b4llhxe3hjbgv"]
|
[gd_scene format=3 uid="uid://b4llhxe3hjbgv"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://bo7jao24qe2o7" path="res://scenes/game.gd" id="1_lbhrr"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bnv1xxgceqbrc" path="res://scenes/world.tscn" id="1_uwrxv"]
|
[ext_resource type="PackedScene" uid="uid://bnv1xxgceqbrc" path="res://scenes/world.tscn" id="1_uwrxv"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cbvi51vvpt7mu" path="res://scenes/hud.tscn" id="2_yqjtg"]
|
[ext_resource type="PackedScene" uid="uid://cbvi51vvpt7mu" path="res://scenes/hud.tscn" id="2_yqjtg"]
|
||||||
[ext_resource type="PackedScene" uid="uid://nca1hcujxru0" path="res://scenes/elevator_panel.tscn" id="3_lnu2h"]
|
[ext_resource type="PackedScene" uid="uid://nca1hcujxru0" path="res://scenes/elevator_panel.tscn" id="3_lnu2h"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bb0o3ov6u308v" path="res://scenes/component_spawn.tscn" id="5_iywne"]
|
||||||
|
|
||||||
[node name="Game" type="Node3D" unique_id=1456297160]
|
[node name="Game" type="Node3D" unique_id=1456297160]
|
||||||
|
script = ExtResource("1_lbhrr")
|
||||||
|
|
||||||
[node name="World" parent="." unique_id=831374579 instance=ExtResource("1_uwrxv")]
|
[node name="World" parent="." unique_id=831374579 instance=ExtResource("1_uwrxv")]
|
||||||
|
|
||||||
|
|
@ -15,3 +18,5 @@
|
||||||
[node name="CanvasPanel" type="CanvasLayer" parent="." unique_id=667193210]
|
[node name="CanvasPanel" type="CanvasLayer" parent="." unique_id=667193210]
|
||||||
|
|
||||||
[node name="ElevatorPanel" parent="CanvasPanel" unique_id=574176994 instance=ExtResource("3_lnu2h")]
|
[node name="ElevatorPanel" parent="CanvasPanel" unique_id=574176994 instance=ExtResource("3_lnu2h")]
|
||||||
|
|
||||||
|
[node name="ComponentSpawn" parent="." unique_id=649225939 instance=ExtResource("5_iywne")]
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,19 @@ extends CharacterBody3D
|
||||||
var speed: int = 5
|
var speed: int = 5
|
||||||
var clumsiness: int = 0
|
var clumsiness: int = 0
|
||||||
|
|
||||||
|
@onready var safety_zone = get_node("/root/Game/World/ElevatorDoors/ElevatorSafeZone")
|
||||||
|
|
||||||
func start(xform):
|
|
||||||
transform = xform
|
#func start(xform):
|
||||||
velocity = (-xform.basis.z * speed).rotated(Vector3.UP, randf_range(-PI/4, PI/4))
|
#transform = xform
|
||||||
|
#velocity = (-xform.basis.z * speed).rotated(Vector3.UP, randf_range(-PI/4, PI/4))
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
velocity.z -= speed * delta
|
velocity.z -= speed * delta
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
func _on_area_3d_area_entered(area: Area3D) -> void:
|
func _on_area_3d_area_entered(area: Area3D) -> void:
|
||||||
var safety = %ElevatorSafeZone
|
var safety = safety_zone
|
||||||
if area == safety:
|
if area == safety:
|
||||||
print("Safe!")
|
print("Safe!")
|
||||||
|
queue_free()
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@ size = Vector3(9.291687, 1, 1.9597168)
|
||||||
|
|
||||||
[node name="World" type="Node3D" unique_id=831374579]
|
[node name="World" type="Node3D" unique_id=831374579]
|
||||||
|
|
||||||
|
[node name="Camera3D" parent="." unique_id=691202574 instance=ExtResource("1_f3sb7")]
|
||||||
|
transform = Transform3D(-0.9999863, 0.005235964, 8.742278e-08, 0.005235964, 0.9999863, 0, -8.7421576e-08, 4.577425e-10, -1, 0.003270626, 2.9093587, -9.910637)
|
||||||
|
fov = 90.0
|
||||||
|
|
||||||
[node name="Hall" type="Node3D" parent="." unique_id=2096979798]
|
[node name="Hall" type="Node3D" parent="." unique_id=2096979798]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.10000013, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.10000013, 0)
|
||||||
|
|
||||||
|
|
@ -29,20 +33,17 @@ transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0
|
||||||
[node name="HallBlock0" parent="Hall" unique_id=1901572100 instance=ExtResource("1_tlwt5")]
|
[node name="HallBlock0" parent="Hall" unique_id=1901572100 instance=ExtResource("1_tlwt5")]
|
||||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, -5.4)
|
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, -5.4)
|
||||||
|
|
||||||
[node name="Camera3D" parent="." unique_id=691202574 instance=ExtResource("1_f3sb7")]
|
[node name="Enemy Placeholder" type="StaticBody3D" parent="." unique_id=133407620]
|
||||||
transform = Transform3D(-0.9999863, 0.005235964, 8.742278e-08, 0.005235964, 0.9999863, 0, -8.7421576e-08, 4.577425e-10, -1, 0.003270626, 2.9093587, -9.910637)
|
|
||||||
fov = 90.0
|
|
||||||
|
|
||||||
[node name="StaticBody3D" type="StaticBody3D" parent="." unique_id=133407620]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.6470537, 0, 4.4912777)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.6470537, 0, 4.4912777)
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="StaticBody3D" unique_id=996721213]
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="Enemy Placeholder" unique_id=996721213]
|
||||||
transform = Transform3D(2.75, 0, 0, 0, 2.75, 0, 0, 0, 2.75, -2.6999998, 2.9387112, 3.8988447)
|
transform = Transform3D(2.75, 0, 0, 0, 2.75, 0, 0, 0, 2.75, -2.6999998, 2.9387112, 3.8988447)
|
||||||
mesh = SubResource("CapsuleMesh_tlwt5")
|
mesh = SubResource("CapsuleMesh_tlwt5")
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" unique_id=1517735028]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Enemy Placeholder" unique_id=1517735028]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.7, 1.048, 3.899)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.7, 1.048, 3.899)
|
||||||
shape = SubResource("CapsuleShape3D_aqk2v")
|
shape = SubResource("CapsuleShape3D_aqk2v")
|
||||||
|
disabled = true
|
||||||
|
|
||||||
[node name="ElevatorDoors" type="Node3D" parent="." unique_id=351419432]
|
[node name="ElevatorDoors" type="Node3D" parent="." unique_id=351419432]
|
||||||
|
|
||||||
|
|
@ -60,4 +61,9 @@ transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 4.5, 2.9909716, -8.27242)
|
||||||
transform = Transform3D(-4, 0, 3.496911e-07, 0, 4, 0, -3.496911e-07, 0, -4, -4.4, 2.9909716, -8.27242)
|
transform = Transform3D(-4, 0, 3.496911e-07, 0, 4, 0, -3.496911e-07, 0, -4, -4.4, 2.9909716, -8.27242)
|
||||||
|
|
||||||
[node name="Survivor" parent="." unique_id=510103859 instance=ExtResource("3_4wyf3")]
|
[node name="Survivor" parent="." unique_id=510103859 instance=ExtResource("3_4wyf3")]
|
||||||
transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 1.3680804, 1.6999999, 4.7656555)
|
transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0.9680804, 1.8453895, 5.186021)
|
||||||
|
|
||||||
|
[node name="SuvivorSpawn" type="Marker3D" parent="." unique_id=1095768768]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.9181392, 13.711893)
|
||||||
|
gizmo_extents = 1.46
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue