Skip to content

Specific Rooms

kobewi edited this page Nov 20, 2025 · 4 revisions

Room-specific things that show various features.

Right Staircase - map collectible, secret wall

RightStaircase.tscn has a map item collectible that discovers part of the world's map. It also has a secret, which is a storable object without marker and creates a cell override to show the newly discovered path. Notice how the map updates when you enter the fake wall area (it's located on bottom right of the room).

TileMap node has a script that disables collision on the Fakeground layer (i.e. fake wall). MapItem is it's own scene, Secret node handles the override.

Lava Corridor - room group override, scene assign override, custom object IDs

A corridor with lava. The interesting fact about it is that it uses 2 scenes: LavaCorridor.tscn and LavaCorridorAfterwater.tscn. After a certain condition is met, the assigned scene is changed to the latter one, so entering this room's cell will switch to a different scene without lava. The color of the cells on the map also changes.

Overrides are performed in LeftStaircase.tscn, but another interesting thing is the orb in this room. It exists in both scenes, yet MetSys can correctly deduce that you collected the orb previously registered in another scene (the orb is inaccessible until you get rid of the lava). It's thanks to object_id metadata, which for both orbs is lava_orb. This allows to register and store the same object in different scenes.

Left Staircase - unlocking shortcut, one-time switches

LeftStaircase.tscn shows how to make a persistent event button. When the player touches the blue button, it will switch to pressed state and emit the pressed signal. The button is a storable object; it's stored on the first press, so when entering the room afterwards, it's pressed immediately (it still emits the signal to notify other objects).

The receivers of the signal is GateOpen node and Pipe. GateOpen will disable the Gate TileMap layer, opening the shortcut. The pipe will start animation when it receives the signal. However it keeps a separate event (in an event array unrelated to MetSys), so when the button notifies it again when entering the room, the animation will be skipped.

Portal Room - moving between map layers

PortalRoom.tscn is one of the portal rooms. It has a Portal node responsible for changing layers. Although in fact the layer changing comes indirectly. What the portal does is changing the scene, the actual layer is assigned in MetSysGame.gd in load_room() method.

Dark Staircase - irregular room with off-map drawing, teleport between rooms

When a room is not rectangular, there will be space where camera can go outside the map. This can be handled in multiple ways. The simplest one is just drawing tiles outside the map, so that player won't see empty space. This approach can be unreliable. Other ways involve drawing a plain color/pattern outside the map or constraining the camera to be only within the used cells. Both can be achieved by using get_local_cells() method. DarkStaircase.tscn shows the latter approach, i.e. drawing plain color; the code is in Outside node.

In this room there is also a small portal. When you enter it, you get teleported to another room on the same layer. This is done simply by loading the other room, but ensuring proper player position after exiting is not obvious, because the previous map is freed before the new one is loaded. The trick is to use a static method to perform something after changing maps.

Dice Room - procedurally generated rooms

DiceRoom.tscn and the related Junction.tscn contain the most complex logic in the sample project. Touching the dice inside the Dice Room will generate a couple of procedural rooms and put a collectible into the furthest one of them.

The whole script for generating rooms is in the Dice node. The general idea is that it generates a virtual grid of connected rooms and puts a collectible in the room furthest from the start. The grid is then translated into map cells and added via MapBuilder. Check the Dice script for details.

The generator uses an important trick - the newly created cells don't correspond to real scenes. They are stored as a string containing information about the rooms, i.e. which sides are open and whether there is an orb. The Game will load Junction.tscn and setup it according to the scene "path". The logic that handles it is in Game.gd's _load_room().

Loop Room - rooms looping in unexpected ways

LoopRoom1.tscn, LoopRoom2.tscn and LoopRoom3.tscn are examples how to make confusing room transitions. When going between rooms you may go to a different room than expected or get looped back to the same room.

The main logic is handled by LoopScript.gd, which should be attached to Area2D. When player is inside the area, going outside the room will cause the loop to take effect. There script can work in 2 modes:

  • Teleport: When the player goes outside the map (i.e. is not in any cell when looping).
  • Replace: When the player goes to another different room.

The loop script will teleport the player, similar to portals, but the logic is a bit different depending on the mode. The player's position also needs to be adjusted manually.

Note that the example looping behavior is not perfect, because looping to the same room may load it again and discover parts of map that technically weren't visited. Ironing it out requires changes to the main MetSys script.

Misc

Some rooms not really related to MetSys itself.

  • ElevatorRoom.tscn shows how to make a Metroid-esque elevator to move between rooms. Related: Elevator.tscn.
  • EndingPoint.tscn has example ability and an ending point based on collectibles.

Clone this wiki locally