Godot 4.4
Hello, I am making a game that generates a set number of rooms, each being their own instanced scene, from an array defined in the main scene. Here is the code for room generation in the main script for reference:
var rooms = {
1: load("res://Scenes/Main/Rooms/hallwayroom_1.tscn"),
}
var last_room
var endpoint
func _ready():
generate_rooms()
func generate_rooms():
last_room = $entranceroom
for i in range(1,50):
var newroom_instance = rooms[randi_range(1, 1)].instantiate()
endpoint = last_room.find_child("End").get_global_position()
get_tree().get_root().add_child(newroom_instance)
newroom_instance.global_position = endpoint
last_room = newroom_instance
I have plans to eventually add an entity that moves along a set path that is included in each room generated, similar to Rush’s behavior in DOORS, where it basically moves on a rail through multiple rooms. The monster will be instanced in the main scene. Assuming the Path3D/Path3DFollow nodes in each room scene use the same start/end coordinates as the start/end markers that indicate where the rooms generate, how would I go about coding the monster so it follows the path through all of the rooms generated in the main scene?