Carrying items between scenes

Godot Version

Godot 4.4.x

Question

Hello,
I’m trying to make a top-down 2D game set inside a building with multiple floors. My plan for how to manage the floors was to put each floor as a separate scene. When going up/down stairs, the player will load in a new scene. However, the character needs to be able to carry multiple different types of boxes between the scenes. I haven’t begun implementing the box carrying system, but I am planning to just instantiate a box scene under the main player scene (I’m open to changing this if it would make the floor-switching system easier).
How should I design the system that tracks what type of box the player is carrying and transfers it to the new scene?
Any help is appreciated, TIA.

You can do this by adding/removing nodes. If (say) your player has a Carrying node and rooms all have Boxes nodes, the rest is pretty simple. When the player picks up a box, remove_child() the box from the room’s Boxes node, and add_child() the box to the player’s Carrying node. When the player drops the box, do the reverse.

Hi, I would set an autoload (global script) with a variable containing whatever the player is carrying. Autoload scripts are availlable in every scene and can be accessed or modified through your whole project so it’s the best way to carry data between scenes. When the player enter a scene, just check this variable in the autoload to see if he carry something and instanciate the proper box. Just look for autoload or global script tutorial on youtube, it takes 2 mins to set and it’s a must.