Feedback on implementing a 2D simple door mechanic

Hello everyone, I’m mostly seeking some feedback on the approach I’m taking for implementing a simple 2D door thing. Picked up Godot 4.2 a few weeks ago and started working on a simple 2D platformer game.

So, I have a level scene with all the level stuff. I built a sepparete scene for the door so I can reuse it easily on my level. Here’s the structure of the door (called ‘UniGate’ on my project):

The behaviour is super simple, when the player is within the Area2D of the entry, the player can make an activation action, and doing so it simply teleports the player to the global position of the Spawn node within the Exit, as a one-way teleport-kind-of thing. It works as intended already.

However, I’m doubting if it was a good idea to do it this way. When placing a door on my level, I have to enable ‘Editable children’ on it, so I can move the Exit node of a particular door wherever I want. But I’m not sure if I I’m happy with that, it certanly clobbers a bit the level scene if I start adding many doors on it. I included both entry and exit ‘objects’ within the same parent, and it seems that in a standard situation, these children should not be moveable when using the root door node on another scene, and be as a fixed pack of stuff.

A bit off-topic but relevant: the door I implemented here has a bit more stuff going on, it can be opened or closed, and it animates both entry and exit, plus there’s some other bools for control and stuff.

What do you think? Is using the ‘Editable children’ advisable in general?

I could rework this, as having a single door object as entry point, and have a node variable in the main script of it that I can set on the editor, to set an empty anywhere on the level scene. I could decorate around this empty with static props, or maybe I can make my main door object spawn a sprite at that location on runtime (I don’t know how to do that yet, but I’m sure it’s possible). But this way, it limits a bit future options (me thinks), and I end up with various empty nodes on the level scene that aren’t strongly connected.

I kinda liked the idea of having a ‘single’ thing that has 2 parts I can move around in the editor and not worry about connecting them, seemed organized to me, but I’m not sure if that is ‘correct’.

Leave me a thought if you like, want to hear how would you approach this specific construct.


You don’t have to make the Area2D a fixed member of Door.
You can make it an export variable: 
@export exit_area:Area2D

The door script handles the signal processing et al on exit_area as you currently do with the Area2D.
When you are creating a level add the doors and for each add an Area2D as a child of that door and place it where you want it. Then just assign the Area2D’s to each of the doors exported exit_area

Ah, nice! I didn’t thought about doing it that way. On my alternative approach I thought about something like that, but it didn’t occured to me to make the extra item on the level for the door (the exit area), a child of the entire door thing.