I am also rather new to Godot and have no experience yet with interconnecting scenes yet, just switching between them. Is that what you want or do you want to do? If so it can be achieved with Marker3D and Area3D. I asked Gemini about this and this is what it came up with:
Yes, Area and Marker nodes are exactly the right tools for this job. It is a very common and efficient way to build an endless room or endless runner system in Godot.
Here is a straightforward architectural approach you can share with them, complete with the basic logic needed to make it work while keeping performance in check.
1. The Room Scene Setup
Each room should be its own separate scene. Inside each room scene, you need three key components:
-
The Geometry: The meshes, walls, floors, and collision shapes.
-
A Marker3D (The Exit Point): Place this node exactly where the next room should begin. It acts as the snap-point anchor.
-
An Area3D (The Trigger): Place this a little bit before the exit door. Make sure it has a CollisionShape3D covering the hallway. When the player walks through this, it signals the game to spawn the next room.
2. The Main Level Manager
Create a main scene (e.g., World or LevelManager) that will handle the spawning logic. This script needs an array to hold the room scenes and a reference to the starting point.
GDScript
extends Node3D
@export var room_scenes: Array[PackedScene]
var current_spawn_point: Vector3 = Vector3.ZERO
func _ready():
# Spawn the very first room at the start
spawn_random_room()
func spawn_random_room():
# Pick a random room from the array
var random_index = randi() % room_scenes.size()
var room_instance = room_scenes[random_index].instantiate()
# Add it to the world
add_child(room_instance)
# Move the room to the current spawn point
room_instance.global_position = current_spawn_point
# Connect the room's trigger Area3D to our script
# Assuming the Area3D in the room scene is named "SpawnTrigger"
var trigger = room_instance.get_node("SpawnTrigger")
trigger.body_entered.connect(_on_player_entered_trigger.bind(room_instance))
# Update the spawn point for the *next* room using this room's Marker3D
# Assuming the Marker3D is named "NextRoomMarker"
var marker = room_instance.get_node("NextRoomMarker")
current_spawn_point = marker.global_position
3. Triggering the Next Room
When the player hits the Area3D, the connected function runs. It needs to verify that the player is the one triggering it, spawn the next room, and then disable the trigger so it doesn’t fire twice.
GDScript
func _on_player_entered_trigger(body: Node3D, room_node: Node3D):
# Make sure it's the player triggering the area, not an enemy or item
if body.is_in_group("player"):
spawn_random_room()
# Disable the trigger so walking back and forth doesn't spawn infinite rooms
room_node.get_node("SpawnTrigger").queue_free()
4. Memory Management (The Crucial Step)
If the player sprints through rooms endlessly, the game will eventually crash from running out of memory. To handle this cleanly—similar to adding and removing data chunks—old rooms must be destroyed once the player is far enough away.
A simple way to handle this is to add a timer, or a second Area3D at the start of the room. When the player enters room 3, a signal tells room 1 to call queue_free(), instantly clearing those meshes and nodes from memory.