For a current unity project I need a layered map like in Dwarf Fortress. The game will take place in a 3D city enviroment and the camera should be 'snapped' to layers. So there will be (for example) a cave layer, ground layer and floor 1 - 3 layer. The player should be able to navigate the camera up and down with a keypress. So if the player is looking currently at the ground layer and press + the camera should snip to floor 1 layer. All layers below the current level will be blurred and all levels above wont be visible (or at least faded out very strong)

My question now is: Is the layer system of unity useful for such a scenario, or is it better to implement an own data structure? I know about the ability of ignoring layers for rendering and raycasting but can the system be extended to support the features described above?

  • \$\begingroup\$ For recent projects (with an engine version of 2017.1.1 or greater) I would definitely recommend having a look at Cinemachine as it provides state driven cameras as well as a free look camera with configurable stages and a lot more. With 2018.x it has also been integrated into UPM (unity package manager) which means that it is stored globally and can be maintained by UPM while not bloating your assets folder. Essentially, it brings a lot of functionality out of the box without the need to code your own behaviours. \$\endgroup\$ – loptrinho Jun 2 '18 at 13:41

I would think using multiple cameras + layers would be your best bet/most flexible.

Each camera can use it's own Culling Mask property to render only selected layers. Using multiple cameras should allow you to apply effects (such as blur) only to selected layers, and using Normalize Viewport Rect you can control where each camera 'draws' to the screen.

So, when a player moves up or down a layer/level you would:

  • Disable cameras above the player
  • Adjust each cameras Normalize Viewport Rect to center the current layer on screen
  • Blur the layer below current layer

Also, in this scenario, where each camera has its own layer/level, each camera can be set to a different Depth which affects its rendering order.

  • \$\begingroup\$ Thank you for your input. I will read up on the topics you brought up. \$\endgroup\$ – floAr Oct 14 '13 at 6:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.