1
\$\begingroup\$

I am wondering what is the most common and best way to design a game in Unity from the point of view of best practice and performance and the most easily maintainable?

Is it really performant to design the level in Unity editor using a GameObject for each part of the level? or should the whole world of the level be designed in any 3D software and then exported to Unity as a on GameObject?

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

This is very project dependent. Every studio, group, and developer has a preferred method.

Generally, you use meshes when it's easier to construct something in your 3D editor rather than the scene editor (objects with geometry that needs to be changed on the fly. Terrain, caves, some buildings, etc). And then use the scene editor to place prefabs, movable objects, instanced scenery, and game logic items.

The performance aspects you mention come into effect with things like occlusion culling, instancing, and draw batching. If the whole scene is one mesh, then EVERYTHING gets rendered every frame which can be costly. This can be somewhat mitigated by splitting up your world geometry into multiple fragments.

So in general, do what you're comfortable with. There are tons of tools and plenty of documentation to make either approach work for you.

\$\endgroup\$
1
  • \$\begingroup\$ There are tons of tools and plenty of documentation to make either approach work for you. Would mention any example of these? I am still relatively new in considering all unity details in my mind (although I am a unity programmer in company, but for some special things). \$\endgroup\$ May 25, 2017 at 12:17
1
\$\begingroup\$

Unity has a quite useful terrain editor which can be used for creating outdoor scenarios. But unfortunately Unity lacks a proper general-purpose editor for indoor levels. So if you want to create an indoor level, then importing it as a 3d model is pretty much the only feasible way to get the level geometry into your scene. I am mostly talking about walls, floors and ceilings here. Any interactable or independently moving objects should be separate game-objects which you place with the editor after importing your level geometry from your 3d modeling program.

However, for some projects it can make sense to build your own level editor into Unity by creating some editor scripts (or downloading one from the asset store). Such an editor could work in form of "building blocks" which can be combined in different ways or in form of creating procedural meshes. The best strategy is highly dependent on the game you want to create.

Also keep in mind that Unity can only do optimizations like frustum culling and LOD-groups on complete 3d meshes, not on parts of one 3d mesh. So when you have very large levels, you might want to break them down into multiple independent game-objects. You might also have to implement some own logic to load and unload (Instantiate and Destroy) parts of the level at runtime to make sure you only have the level geometry in your scene which is currently visible or otherwise relevant for the game.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged .