I’m thinking of using unity for my next project however if wondering if unity can handle randomly generated levels. Specifically can unity generate lighting on the fly if its coded in or does it require lighting to be set up before runtime.
Is there any other issues I may run across using randomly generated levels in unity?
You can use dynamic lights and shadows just fine, but you will not be able to bake a lightmap. One of the biggest issues you’ll face with runtime-generated levels in Unity is that you generally won’t be able to mark anything as “Static” in the inspector, so you can’t use anything that requires “baking”, like static batching, lightmaps, nav meshes or occlusion culling. That general concept is true for pretty much any game engine you use though, so Unity is still a good choice for runtime-generated levels IMO.
Thanks for the heads up! I was aware of most of the restrictions (nav-mesh, occlusion culling,etc) didn’t think about the fact though that nothing could be marked as static which shoulda been pretty obvious
I was mostly worried about lighting since a different engine I used would not allow lighting to be added through code and we ended up needing to have it in the scene already with 0 power and then just adjust the power and positioning when it was activated.
Thanks again!
You actually CAN dynamically lightmap, it just takes a bit of programming. And it’s not technically lightmapping on the fly, you have to make your lightmaps ahead of time and assign them in your level creator. You can acess/set lightmaps for a scene with LightmapSettings.lightmaps. It is an array of lightmaps for the current scene. In your dynamic level creator script, you’ll have to set the correct lightmaps for the level you are using (from the previously created lightmaps you made and stored in a folder. You can get it using Resources.Load)
[Edit]
This actually depends how you plan on making your generated level. If you are putting together levels from pieces, I believe it is possible in Unity 4 to just lightmap certain objects but it’s not the same–and the above method won’t work.