Getting Started#

This tutorial is available on youtube

Verify Installation#

  1. Open a new project

  2. Make sure Plugin content is visible

    Content Drawer / Settings / Show Engine Content [X] Content Drawer / Settings / Show Plugins Content [X]

  3. Load Example Map

    Plugins / GKFogOfWarContent / Example / FogOfWar

  4. Set Game Mode Override

    WorldSettings / GameMode Override / GKFoW_GameMode

Create your own#

Initial Setup#

  1. Create a new Game State from GKFoW_GameState (inherits from AGKFogOfWarGameState)

    Update the team information if need be AGKFogOfWarGameState > Teams > Fog Of War Teams

  2. Create a new Game Mode from GKFoW_GameMode (inherits from AGKFogOfWarGameMode)

    Inside GameMode set the game state to the newly created game state

    Note

    The game mode is used to initialize the Fog Of War before the game starts. You can override AssignTeamFor to customize how teams are assigned to player controller

  3. Set the Game Mode Override

    WorldSettings / GameMode Override / GKFoW_GameMode

  4. Tag the player start with the team name the player should be starting as

  5. Add a AGKFogOfWarVolume to the scene and make it cover the entire map

    Note

    Only one volume can be created per map

    Warning

    The fog of war texture size should not be above 2048x2048 px (8192 / 4) IF GPU/CPU upscaling is enabled (it is by default)

Add obstacles#

  1. Create a new Pawn
    • Add a UGKFogOfWarComponent

    • UGKFogOfWarComponent > GivesVision [ ]

    • UGKFogOfWarComponent > BlocksVision [X]

    • Add static mesh

  2. Place Pawn on the map

Note

You will want to align the obstacles to the fog of war grid to make the bounds match as closely as possible. See Actor snapping.

Add Landscape#

  1. Create a landscape

    Add bumps

  2. Add the landscape to the Fog of War Volume

    Fog Of War Volume / Strategy / Landscape

  3. Make sure the Fog of war is below the landscape

  4. Make sure the Navigation Bound Volume includes the landscape

Custom collision Shapes#

  1. Open an Obstacle Pawn

  2. Add Box/Sphere/Cylinder Collision Shape

  3. Make sure the shape covers the area that blocks visions

  4. Implement the GKFogOfWarAgentInterface
    • Class Settings / Interfaces / Add /  GKFogOfWarAgentInterfaces

    • Implement GetFogOfWarComponent by returning the component

    • Implement GetFogOfWarCollisionShape by returning the shape

Note

Only rectangle, yaw rotated rectangle and circle obstacles are supported.

Update Cylinder Obstacles#

  1. Open an Obstacle Pawn
    • Add Box/Sphere/Cylinder Collision Shape

    • Make sure the shape covers the area that blocks visions

    • Class Settings / Interfaces / Add /  GKFogOfWarInterfaces

    • Implement GetFogOfWarComponent by returning the component

    • Implement GetFogOfWarCollisionShape by returning the shape

Player Starts#

  1. Create a Second PlayerStart

    Change the tag to the enemy team (BadGuys)

  2. Change the Network mode to Clients

    Editor / Change Play Mode / Net Mode / Client

  3. Change the number of players to 2

    Editor / Change Play Mode / Number of Players / 2

Note

You should enable client side navigation for clients to move correctly.

Project Settings / Engine / Navigation System / Allow Client Side Navigation [X]

Debugging#

  1. Navigate to

    Plugins / GKFogOfWar Content / Debug / GKFoW_DecalView

  2. Drag and drop the decal on the map

  3. Scale it to cover the map

  4. Enable debug mode on the Fog of War Volume

Disable auto-exposure#

The fog of war will darken your screen, by default UE has auto exposure enabled which can create a distracting effect when large area are revealed.

  1. Drag a drop a post process volume

  2. Disable Auto exposure

    Post Process Volume / Exposure / Min Brightness / 1 Post Process Volume / Exposure / Max Brightness / 1

  3. Make the Post Process Volume unbounded

    Post Process Volume  /  Volume Settings / Infinite Extent [X]

Details#

Classes#

  • AGKFogOfWarGameState:
  • AGKFogOfWarGameMode:
    • extends AGameMode

    • expose new blueprint event AssignTeamFor used to assign a team to each player controller

  • AGKFogOfWarPlayerController:
    • extends the base PlayerController to make it belong a given team; it handles dynamic team change.

  • AGKFogOfWarCharacter:
    • extends the base Character

    • implements fog of war conditional replication, it is only replicated to enemies if it is seen by them.

  • AGKFogOfWarPlayerState:
    • extends APlayerState

    • expose a new attribute AGKFogOfWarPrivatePlayerState which is only replicated to allies.

  • AGKFogOfWarVolume:
    • Draws the fog of war periodically

  • UGKFogOfWarComponent:
    • Register itself to the Fog of War volume

    • Specify how the actor fog of war should behave (blocks light, provide vision, vision radius)

  • UGKFogOfWarStrategy:
    • Implements how the fog is drawn

  • UGKTransformerStrategyCanvas:
    • Implements material based transformation on the vision texture

    • this is used to implement upscaling and exploration (blending of previous & current vision)

Initialization Flow#

../../../_images/InitializationFlow.png

Replication Flow#

../../../_images/ReplicationFlow.png