Fog of war and vision
Each team sees what its champions, minions, structures and wards can see; everything else is fog. The server works out what each team sees and sends nothing else: an enemy your team does not see does not exist on your game, so a hacked client has nothing to show. Each player's game draws its team's sight as fog on the GPU, in the world and on the minimap. All of it lives in the Vision module.
Turn vision on for a map
- Place one Moba Fog Of War Volume and scale its box over the whole playable area, from below the ground to above the highest wall. A map without one has no vision: every team sees everything.
- Press Build Vision Grid in the volume's details, and save the map.
The grid finds what blocks sight on a 50 cm grid over the volume. Each cell is measured from its own ground, so a map may have ground at several heights, such as Riftwood's lanes and the jungle 300 cm above them. A cell blocks sight:
- where static level geometry stands 150 cm (Blocker Height) above its own ground: walls, big rocks, tree trunks;
- where it is part of a cliff: the ground rises more steeply than 30 degrees (Cliff Angle) from a neighbouring cell, and the steep stretch rises 150 cm or more. Two levels see each other only where a ramp joins them, and a ramp must be gentler than the Cliff Angle.
Units, towers included, never block sight, and neither does anything that is not static world geometry. A volume whose grid is missing, or no longer fits its box, builds the grid when the match starts and says so in the log; on a big map that is a noticeable pause. Build the grid in an editor that has ticked at least once after loading the map, or ground with complex collision may not answer yet and the grid comes out empty. Build it again after you move walls.
Moba.Vision.SaveGrid [file.png] writes the grid as a picture, one pixel per cell, black where sight is blocked; by
default to Saved/VisionGrid.png.
Who sees what
The server works out what each team sees ten times a second (UMobaVisibilitySubsystem):
- Sight. Champions see 1350 cm, minions 1200, structures 1100 and wards 900, center to center on the ground. Give any actor that fights for a team a Moba Vision component to give it vision, with its own Sight Radius. Dead units and fallen structures give none.
- Walls. A blocking cell on the line between the two hides the target. The cells the two stand in do not count, so a unit pressed against a wall still sees and is seen.
- Brush. A unit standing in brush is hidden from enemies outside the patch, even within their sight. Anyone of a team inside the patch, a ward included, shows that team the whole patch. Units in brush see out normally.
- Stealth in brush. A unit with
State.Stealthedstanding in brush is hidden even from enemies in the same patch or with a ward there. Out of brush, stealth changes nothing. Its own team always sees it. - Revealed by attacking. A unit that hits an enemy champion is seen through brush for the next 1 s. It still has to be within someone's sight.
- Always seen. A team always sees its own side, and every structure.
Brush
Draw Moba Brush Volume boxes over the grass meshes, scaled and turned to fit. Boxes that overlap on the ground are one patch, so an odd-shaped patch is a few boxes; separate patches are separate. A unit is in a patch when its center is; the box's height does not matter. The grass meshes need no collision: brush hides, it does not block sight.
Brush and stealth on the unit. On the server, every living unit in a patch carries the tag State.InBrush on
its ability system, and loses it as it leaves, so an ability can fire on it: a passive's Fires On Losing Tags, as
Rook's Ambush does. A unit with State.Stealthed (MobaStealthEffect, which Rook's Shroud keeps on while it is
on) is hidden in brush even from enemies standing in the same patch or with a ward there; out of brush, stealth changes
nothing, and its own team still sees it.
Your own team sees who is hiding. An ally standing in brush, your own champion included, turns see-through on your team's screens: every primitive of the unit gets the custom primitive data float at Brush Fade Data Index (0) set to 1, and 0 when it leaves. In your champions' materials, add a scalar parameter with Use Custom Primitive Data on at that index, and dither the opacity mask from 1 at 0 down to about 0.4 at 1 (a Masked material). The sample's mannequin material does. Hidden Ally Overlay Material can add an overlay for materials that do not read it. On the other team's screens the unit is not there at all.
The grass can part around them. Each player's game fills the material parameter collection MPC_Moba_Brush every
frame: its vectors Parter0 to Parter4 hold the player's own team's champions standing in brush, XYZ the champion's
middle and W the Brush Part Radius (120 cm), with W = 0 for an unused slot. An enemy is never put there, so the grass
cannot give one away. A grass material reads the collection and bends its blades away within W of each parter.
Wards
A Moba Ward gives its team 900 cm of vision for 90 s, then disappears. Enemies who see it kill it with 3 basic
attacks, whatever their damage; abilities do not hurt it, and minions and towers leave it alone. The class has no
mesh: make a Blueprint of it with one and name it in Project Settings > Pioneer MOBA Framework > Vision > Ward
Class. The sample's is /PioneerMOBA/Sample/Ward/BP_Ward.
- The ward key (4) casts
/PioneerMOBA/Vision/DA_PlaceWard, an AoE ability with the classUMobaPlaceWardAbilityand a 90 s cooldown. A ward aimed into a wall goes to the nearest walkable point within 100 cm, or the cast is refused. - Bought wards come from the shop's Vision Ward, whose use has the class
UMobaPlaceBoughtWardAbility: the same ward, standing 150 s. One player has at most 3 bought wards standing; placing another removes that player's oldest.
In code, AMobaWard::Place puts one down, and AMobaWard::FindBoughtWards finds a player's.
What each player is sent
An enemy a team does not see is not replicated to that team's players at all. Their game removes its actor, and creates it again where it stands when it comes back into sight; nothing about it arrives in between. Projectiles and other replicated actors a unit spawns follow their unit's side: an arrow fired from the fog arrives when it flies into sight.
This runs on Iris, with two exclusion groups, one for what each team does not see. Group filters cost nothing per frame; only the changes are applied. A champion's health, mana and effects, which live on its player state, are kept back the same way, and so are its Gameplay Cues; see Multiplayer. A player who is also the server, as the host of a listen server is, has every unit in their world; there, what their team does not see is hidden on screen instead.
Bots see only what their team sees, as players do.
The fog
Each player's game draws its team's sight into a fog texture on the GPU every frame (UMobaFogRenderer): for each
texel, whether it lies within a sight source's radius with no blocking cell between them. Fog edges fade over the blend
time, and a wall's face counts as seen. A post-process material darkens and greys the world where the texture says it
is fogged. There are two states, seen and fogged; nothing is black and unexplored.
The minimap reads the same texture (GetFogTexture, GetFogArea), so the two always match. The texture covers the
Fog Of War Volume's box, which is also the area the minimap's picture spans. The fog is a picture only: the server
decides what is sent, so at an edge an enemy may appear a frame before or after the fog clears.
The fog's look is set on the volume: Fog Texture Size (512), Fog Blend Time (0.25 s), Fog Darkness (0.6), Fog Desaturation (0.7), the post-process material, and the Minimap Texture, the picture of the map the minimap shows.
Settings
Project Settings > Pioneer MOBA Framework > Vision:
| Setting | Default |
|---|---|
| Champion, Minion and Structure Sight Radius | 1350, 1200 and 1100 cm |
| Vision Update Rate | 10 Hz |
| Vision Grid Cell Size | 50 cm |
| Blocker Height, Cliff Angle | 150 cm, 30° |
| Always Relevant Structures | on |
| Ward Class, Ward Sight Radius, Ward Lifetime, Ward Hits | the sample's BP_Ward, 900 cm, 90 s, 3 |
| Ward Snap Distance | 100 cm |
| Bought Ward Lifetime, Max Bought Wards | 150 s, 3 |
| Reveal On Attack Duration | 1 s |
| Show Hidden Allies, Brush Fade Data Index, Hidden Ally Overlay Material | on, 0, none |
| Brush Collection, Brush Part Radius | MPC_Moba_Brush, 120 cm |
| Fog Material | M_Moba_FogPostProcess |
Debugging
Outside Shipping builds:
moba.Vision.Debug 1draws each team's sight circles and marks what each team does not see, on the server's world in Play In Editor.moba.Vision.ShowAll 1sends everything to everyone.Moba.Vision.SaveGridwrites the vision grid as a picture.