Creating new buildings in game that you can enter as a new scene.

Hello,

I am trying to figure out the best approach when it comes to letting the player build new buildings which can be entered (interior would be larger than the sprite footprint so would be a separate scene).

So if the player could only build one instance I’m pretty sure the solution would to place a prefab down on the map which already has the properties to warp to the new scene included. But if there was no set limit to the amount of buildings the player could place how is that best handled? Think how multiple barns can be placed down in stardew valley.

I thought about having a single scene for every instance and depending on which one was entered you would just load the items in for that building and save what was in there on an exit, but that approach doesn’t seem quite sound.

I am only a couple weeks into using Unity, but am very experienced with C# (10+ years of using it professionally). In my current game I just have static buildings that the player can enter, and I know I’m a long way off from implementing this functionality, but I wanted to have an approach in mind in case I need to make considerations for it earlier.

Thank you!

Welcome to the forums!

Off the top of my head, my thinking is like this: You’d have a prefab for each type of building. And when you place one down, you create a new instance that gets a unique ID. When the player enters, load the interior scene/prefab for that building type, with the layout/contents of the particular instance based on the ID.

Does that make sense?

Yes, that makes perfect sense, thank you! My wording may have been off but that was the approach I was leaning towards, I’m just glad that someone who is more familiar with Unity sees this as a viable approach. Thanks again!

1 Like