How to Instance Customizable Rooms?

Godot Version

Godot_v4.5-stable_win64.exe

Question

The game is a 2D mobile game that has a pet house feature. You are provided with your first ‘room’ and have the option to purchase another ‘room’ which you can access by swiping left(/right). You can decorate each room with furnitures, and each room holds the pet you place in them etc. So each room is basically customizable. The first idea was to instance a premade room tscn with its scripts and signals etc to an hboxcontainer on the pet house scene but I’m not sure on how to make each room keep the customizations made on them (furnitures placed and its position in the room, the specific pets that should be in the room, wallpapers, etc). Will they be stored and controlled in a resource file somehow? or maybe each new room instanced is saved as it’s own new scene?

I’m a noob in game dev and I’d like to know things like any standardized ways or maybe some features in godot I’m not aware of (many) and if there’s just any suggestions on how I could make this work, thanks!

You could make an Owen resource that holds all your room data.
To spawn a room you could instantiate a parent node with a script attached that holds your resource and spawns all your sub scenes on ready.

Possible way to save furniture/ etc. in your resource:

create a new furniture class with following attributes (example):

  • name : string
  • position : Vector2
  • color : Color

save your furniture as objects in an array.
Also have a constant dictionary that holds every type of furniture (key = name) with the according scene path to instantiate)

If you want to spawn your rooms in the editor as well you can make your spawner script a tool script and update your child nodes by deleting them and respawning the room if your resource changes.

Hope this helps. Might be a little confusing:)

1 Like