Skip to content

Add Terrain Types and Vision Layers

Goal. Two things, in two parts.

  1. Three terrain types: Mud (slow, and units avoid it), Road (fast) and Forest (units see less far). One more type, Water, which Soldiers cannot enter.
  2. A Thermal vision layer. A Scout Drone sees on it. An Infiltrator can be seen only on it, so it is invisible to ordinary sight and appears when the drone is near.

Read Navigation and Level Data and Fog of War first. You need a baked level with units that move and have vision, such as the demo’s LVL_Game.

Add four gameplay tags: SeinARTS.Terrain.Mud, SeinARTS.Terrain.Road, SeinARTS.Terrain.Forest and SeinARTS.Terrain.Water. Use Add New Gameplay Tag in any tag picker, or Project Settings > Project > Gameplay Tags. The framework ships no terrain tags. They are yours.

Open Project Settings > Plugins > SeinARTS, find Terrain, and add four elements to Terrain Types:

Terrain Tag Nav Cost Speed Multiplier Vision Multiplier Debug Color
SeinARTS.Terrain.Mud 4 0.5 1 Brown
SeinARTS.Terrain.Road 1 1.5 1 Grey
SeinARTS.Terrain.Forest 2 0.8 0.6 Green
SeinARTS.Terrain.Water 1 1 1 Blue

The three numbers are separate dials. Nav Cost steers the pathfinder’s cell search, from 1 (normal) to 254, and never makes a cell impassable. Speed Multiplier scales a unit’s speed while it stands there. Vision Multiplier scales the sight radius of a unit standing there. Speed and vision are floored at 0.05.

A road cannot be cheaper than open ground, because the cost floor is 1. Units use a road when it is on the way, and they cross it quickly, but it does not pull them off a direct route.

Mark areas of the map in either of two ways. Both write the same result at bake.

With volumes. From Place Actors, add a Sein Terrain Volume. Scale it over the area. Set its Terrain Type to the tag, such as SeinARTS.Terrain.Mud. Where volumes overlap, the one with the higher Priority wins, so give a small mud patch inside a big forest a higher number than the forest. A volume always overrides the type its material would give.

With materials. Add the physical materials that mean mud, road or forest to the type’s Physical Materials list in step 2. Give those physical materials to the surfaces: set one on a landscape layer’s Layer Info, or on the material of a mesh. Any cell whose surface hits one of them becomes that type. This uses the paint tools you already have.

For the test, place a Mud volume 400 units wide across a straight line between two points, with open ground around it, and a Road volume along another line.

Select a Sein Level Volume and press Bake Level Data. Terrain types are stored in the bake, so changing them or the terrain always needs a new one.

To check the result, run Sein.Nav.Show in the console. Walkable cells tint by each type’s Debug Color. Open ground is green.

Play and send a Soldier (Speed 350) across each area:

  • Across 700 units of open ground it takes 2 seconds. Across 700 units of mud it moves at 175 units a second and takes 4. Along 1,050 units of road it moves at 525 units a second and takes 2.
  • Order it between two points with the Mud patch directly between, on open ground. It walks straight through at half speed: the route is straightened along any line clear of blockers, and terrain cost does not break a line.
  • Build a wall with two gaps, and put the Mud patch in the nearer gap. The cell search charges 4 per unit of mud, so crossing 400 units of it costs as much as 1,600 units of open ground. The Soldier takes the other gap if that adds less than 1,200 units.
  • Stand a Soldier with its Sein Vision at the default radius 1000 in the Forest: its sight shrinks to 600. Sein.FogOfWar.Show shows it.

Costs never forbid a cell. To forbid one, list the tag on the unit. Open the Soldier’s Sein Navigation component and add SeinARTS.Terrain.Water to Blocked Terrain Tags. This does not block a type tagged SeinARTS.Terrain.Water.Deep, so list that tag too if you add such a type. Listing the child tag alone blocks both types.

The unit’s rule is read at run time and needs no rebake, but the Water volume does. Place a Water volume across a stretch of ground, rebake, and order a Soldier over it: it routes around, or goes as near as it can if there is no way round. A unit without the tag walks straight through.

Open Project Settings > Plugins > SeinARTS, find Fog Of War, and expand Vision Layers. Its six slots are already there, all disabled. Open slot 0. Tick Enabled and set Layer Name to Thermal. Slot 0 is the N0 bit.

The names Normal and Explored are reserved. The name only labels the layer for queries and the debug viewer. Matching below is by bit.

Open the drone’s Blueprint, select its Sein Vision component and add a second element to Vision Stamps. Set its Radius to 1500. In Layer Mask, untick V (Normal) and tick N0. The drone’s first stamp stays on V, so it still sees as usual.

9. Make the Infiltrator seen only by thermal

Section titled “9. Make the Infiltrator seen only by thermal”

Open the Infiltrator’s Blueprint and select its SeinARTS Entity Bridge component. Set Fog Visibility Layer Mask to N0 only. Leave Fog Visibility Policy on Vision Layers Only. Enemy Soldiers standing next to the Infiltrator cannot see it, because their stamps paint V and the Infiltrator is only revealed on N0.

To switch it at run time, create an ability SA_Cloak. On Event On Activate, call Remove Entity Emission Layers on the Owner Entity, with Layers To Remove V (Normal). The unit still emits on the other bits, so thermal sight still finds it. On Event On End, call Add Entity Emission Layers with V to uncloak.

Place a Sein Fog Of War Render if the level has none (the demo’s level already does). Open its Vision Layer Post Process Materials and open slot 0: tick Enabled, set Post Process Material to a post-process material that restyles the screen (a heat palette, say), and tick Combine With Normal Vision if the player should keep normal sight while the view is on. With it off, the view shows only what the layer sees. The style material draws under the fog, so unexplored ground stays black either way.

Switch the view. For a quick test, run Sein.Vision.Layer 0 in the console, or Sein.Vision.Layer with no number to cycle. For players, bind a key in your Player Controller Blueprint: Get Actor Of Class (Sein Fog Of War Render), then Cycle Vision Layer. Set Active Vision Layer takes -1 for Normal and 0 to 5 for a custom slot, and ignores a slot that is disabled.

Put Player 1’s Scout Drone and an enemy Soldier with the Infiltrator near each other.

  1. The enemy Infiltrator is 2,000 units from the drone. It is not visible: it is outside the drone’s 1,500 thermal stamp.
  2. Move the drone to 1,000 units. The Infiltrator’s actor appears.
  3. Put a Player 1 Soldier beside the Infiltrator without the drone nearby. It stays hidden.
  4. Switch the view to Thermal. The fog now reveals the area the drone sees on N0.
  5. Sein.FogOfWar.Show.Layer 2 draws the N0 cells (0 is Explored, 1 is Normal, 2 to 7 are N0 to N5).
  • A terrain type has no effect. The level was not rebaked. Or the volume’s tag is not in Terrain Types: an unknown tag resolves to Default.
  • Material terrain does not appear. The physical material is not on the surface that is hit. Landscape layers need it on their Layer Info. A Sein Terrain Volume overrides the material, so a volume over it hides the difference.
  • Units cross mud instead of going around. On open ground that is expected: the straightened route ignores cost. Where obstacles force the route, the way around costs more than the mud, so raise Nav Cost or shrink the patch. The cost per cell is capped at 254. To forbid the mud, use Blocked Terrain Tags.
  • Units avoid a road. They do not. Roads are never cheaper than open ground, so units do not detour for one. Raise the cost of the terrain beside it if you want them funneled.
  • Units are slow but still route straight through. Speed Multiplier slows the unit and does not change the route.
  • A Water volume does not stop a unit. The tag is not in its Blocked Terrain Tags, or it is on a different unit class.
  • The slot’s name is not accepted. Normal is reserved. A disabled slot cannot be found by name, though its bit still works.
  • Nothing is revealed on N0. The stamp’s Layer Mask has no N0 bit, or the target’s Fog Visibility Layer Mask does not share a bit with any of the observer’s stamps.
  • Set Active Vision Layer does nothing. The slot is disabled, or the layer index is out of range. A slot with an empty Post Process Material changes only the revealed area.
  • Layers behave differently after you edit the slots. You inserted or reordered a slot. Every higher bit moved, and saves and replays no longer line up. Only append a slot or rename one.
  • The two sides see different things. Vision Layers are part of the simulation settings. Every player needs the same values.