Menu
Lumberyard
User Guide (Version 1.14)

Streaming and Switching Layers

This topic references tools and features that are legacy. If you want to use legacy tools in Lumberyard Editor, disable the CryEntity Removal gem using the Project Configurator or the command line. To learn more about legacy features, see the Amazon Lumberyard Legacy Reference.

Layer streaming and layer switching control the visibility of all entities and geometry on a level in real time. Without the efficient use of layer switching, game performance can quickly degrade. It is important to find suitable locations within a level where layer switching should take place, such as between rooms, or between indoors and outdoors for example.

The following guidelines and limitations apply to layer streaming and switching:

  • Make sure that all of the layers are visible (not hidden) in the Lumberyard Editor. If you hide layers in the editor, they will not be visible in the game, and flow graph cannot unhide them. You can, however, use flow graph to hide layers that are visible in the editor.

  • Set the Load by default option on the layer settings, or else the layer won't unhide correctly.

  • Triggers inside a hidden layer do not function so do not switch layers that contain triggers.

  • Physics proxies are not affected by layer switching.

  • Use the es_LayerDebugInfo 1 console variable to display all active layers for debugging purposes.

  • Use the e_ObjectLayersActivation 1 console variable (default is 0) to activate layer switching.

Layer Streaming

Layer streaming is disabled by default. To use it, you must first enabled it.

To enable layer streaming

  1. In the Rollup Bar, on the Terrain tab, click Environment.

  2. Under EnvState, select Use layers activation.

Layer Switching

You use Flow Graph to set up the switching of layer visibility. The logic is simple:

  1. Start the game.

  2. Hide layer B and show layer A when the player is in proximity.

  3. Switch visibility when the player is going from location A to B.

The following figure shows the flow graph node used to switch layers.

To switch layer visibility

  1. In the Rollup Bar, on the Objects tab, click Entity.

  2. Under Browser, expand Default and double-click FlowgraphEntity.

  3. Scroll down to the Flow Graph section if needed and click Create.

  4. Type a group name for the Flow Graph and click OK.

  5. In the Flow Graph window, under Flow Graphs, select FlowgraphEntity1.

  6. Right-click anywhere in the graph, and then click Add Node, Engine, LayerSwitch.

  7. In the Engine:LayerSwitch node, double-click Layer= and choose a layer from the list to be switched. Then connect the following inputs and outputs as needed.

    • Hide – Input that hides the layer.

    • Unhide – Input that makes the layer visible.

    • EnableSerialization – Input that enables layer serialization.

    • DisableSerialization – Input that disables layer serialization.

    • Hidden – Output that signals that the layer is now hidden.

    • Unhidden – Output that signals that the layer is now visible.