I am randomly creating a city from a selection of randomly generated building tiles. I want to make it so the player can enter any of these buildings. The way I see it, there are two ways I can do this:
Create the rooms as part of each
buildings mesh and rely on using
occlusion so the scene is only ever
rendering the rooms the player can
see. Each room will also have
randomly generated items, so I'm not
sure if this technique will work?
Generate a room only when the player
enters the buildings door. This
seems like the most efficient
technique as I'll only be rendering
the rooms that the player has
'opened'. The problem here is that
when the user opens a door, the room
behind it needs to load in
seamlessly without a loading screen,
how would I get around that?
If anyone has any ideas, I'd really appreciate some advice.
Just for clarification, when you say "Each room will also have randomly generated items, so I'm not sure if this technique will work?", what about that technique will fail?
Sorry, I'm not sure why I added that. It should be simple enough to occlude my items too.
Answer by DaveA
Jul 13, 2011 at 03:25 PM
You can use proximity and visibility to take a good guess at when to start loading rooms.
You can, for example, put a box collider somewhat larger than your building where the building will be. When a player enters that bound, start loading the interior. He may not go in, so that may be a waste. In that case, you could check the visibility of the collider (or building) to see if the user is looking in that direction. You can also check his velocity to see if he is moving toward the building. BTW the proximity bound need not just be a simple box larger than the building. It can be any shape, or group of shapes. For example, you could put small boxes in streets and alleys that trigger the loading. You see many games where there's sorta an 'airlock' where you enter a small hallway and need to go through a door at the end. This is why. Entering the small hallway loads the content behind the next door.
You can load scenes additively. A scene may have its own occlusion culling in it, so if you do it that way, at least the interiors can be optimized.
I would love to see more LOD (load-on-demand and level-of-detail) support in Unity to support this type of thing. I saw it in Unreal and it's amazing. I've seen it in VRML/X3D too, for a long time. And I know people have coded it themselves in Unity (I heard all of Paris is in Unity this way), but an Asset Store package would be wonderful. Or better (for us) just make it part of Unity 3.5
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
4 People are following this question.
accessing variables from nearby gameobjects (Prim's Algorithm)
Randomly Generated Dungeons?
How can i make an infinite level?
pre generated world
How to save a scene that you randomly generated as a new level in your build settings?