Files
fps_project_1/scripts/sublevel.gd
2025-05-04 23:35:43 -05:00

34 lines
797 B
GDScript

extends Node3D
@export var tube_top : SpawnTube
var offset_pos
const CHEST_1 = preload("res://chest1.tscn")
func _ready() -> void:
if tube_top != null:
position = -tube_top.position
spawn_chests()
func spawn_chests():
var chest_spawners = get_tree().get_nodes_in_group("chest_spawner")
if chest_spawners.size() > 0:
for i in chest_spawners:
i.visible = false
var number_chests = 3
while number_chests > 0:
var chest_loc = chest_spawners.pick_random()
var instance_chest = CHEST_1.instantiate()
add_child(instance_chest)
instance_chest.global_basis = chest_loc.global_basis
instance_chest.global_position = chest_loc.global_position + chest_loc.random_box_pos()
print("CHEST SPAWNED AT : ",instance_chest.global_position)
number_chests -= 1