Before updating to Windows 10 you may need to return your Pro license. More information here

Randomly generated city - Creating rooms

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:

  1. 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?

  2. 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.

more ▼

asked Jul 13, 2011 at 03:20 PM

avatar image

522 144 112 128

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?

Jul 13, 2011 at 03:37 PM Jerdak

Sorry, I'm not sure why I added that. It should be simple enough to occlude my items too.

Jul 13, 2011 at 03:39 PM Disaster
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Jul 13, 2011 at 03:25 PM

avatar image

34.7k 420 360 562

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Jul 13, 2011 at 03:20 PM

Seen: 2460 times

Last Updated: Jul 13, 2011 at 03:39 PM