spawner can now spawn 3d models

This commit is contained in:
Luca 2024-09-17 20:06:11 +02:00
parent ccd3ef577c
commit f025f89401
10 changed files with 59 additions and 34 deletions

View file

@ -8,7 +8,7 @@ extends Node3D
@onready var spawn_timer: Timer = Timer.new()
# list that holds all spawnable monsters
@export var spawnable_monsters: Array[MonsterStats]
@export var spawnable_monsters: Array[PackedScene]
# the maximum amount of spawned monsters
# no monsters will spawn, when this number is reached
@ -48,17 +48,14 @@ func spawn() -> void:
var spawn_point_z = randf_range(-max_distance_spawn, max_distance_spawn)
# instantiate a monster .tscn scene
var monster_to_spawn = spawnable_monsters[0]
var monster_to_spawn = spawnable_monsters[0].instantiate()
# TODO: Replace this with actual instantiation of a walking monster
var mesh_instance = MeshInstance3D.new()
mesh_instance.mesh = BoxMesh.new()
# calculate the position of the monster and add the offset of the spawnpoint itself
var monster_position = Vector3(spawn_point_x, 0.2, spawn_point_z)
mesh_instance.position = monster_position + position
monster_to_spawn.position = monster_position + position
var debug_level_node = get_node("/root/Main/CurrentLevel/DebugLevel")
debug_level_node.add_child(mesh_instance)
debug_level_node.add_child(monster_to_spawn)
print("spawning mob")
# Called every frame. 'delta' is the elapsed time since the previous frame.