Fog Of War Module
This module is an integration of the Fog Of War asset on the Asset Store.
Features
- Enables using fog of war on unit and building entities for both single player and multiplayer modes.
- Selection is only enabled for entities that are visible.
- Minimap icons are only for the entities in areas visible by the local player.
- Building placement can only occur within visible areas by the local player (for the player’s local faction).
- More limitations on entity to entity interactions when it comes to different visibility statuses.
Installation
- Import the RTS Engine (or back up your project if you already have it imported).
- Import the Fog Of War asset from the Asset Store into your project.
- Get the Fog Of War Module and import it into your project.
Guide
Follow the UserGuide of the Fog of War asset to setup the asset for Legacy Renderer, PPSv2, HDRP or URP.
The integration module currently only supports Legacy Renderer mode. Other modes require more tweaking and probably different configurations and will be supported in the future.
1. Legacy Renderer
The scene fog_of_war_demo on the path: RTS Engine -> Modules -> FogOfWar -> Scenes provides an example where the fog of war asset is used with examples of unit and building prefabs.
1.1 Setup Scene
Open a map scene and do the following:
Attach the FogOfWarLegacy component to the main camera object and other cameras you have in the map scene including the minimap one. If the minimap camera is not always rendering (takes a snapshot in the beginning of the game then is disabled) while there is a dedicated minimap UI camera that is always rendering and responsible for minimap elements only then add the FogOfWarLegacy component to the minimap UI camera instead.
Create an empty game object as child of the GameManager object (to keep things organized, you might want to have this new empty object as a child object of GameManager -> Modules), call it FogOfWar and attach the FogOfWarTeam (from the FoW asset) which allows you to define the size of the war among other configurations explained in the FoW asset's documentation. On the same game object, attach the Fog Of War RTS Manager (from the integration module) component and set the Fog Of War Cameras fields to the cameras used in the map scene which we added the FogOfWarLegacy components to in the last step.
1.2 Setup Faction Entity Prefab
For each faction entity prefab (Unit, Building or Resource Building), add the Fog Of War Entity component to the main or child objects of the prefab.
Set the fog of war asset specific fields and most importantly the shape and the size fields. Otherwise, set the following RTS Engine specific fields:
- Minimum Fog Strength: If the fog strength/intensity is smaller than this value then the entity will be visible.
- Visible If Free: Make the entity always visible to the local player if it is a free entity (does not belong to any faction).
- Is Visible Post Discovery: Always visible post after discovery by local player? As soon as the entity is visible to the player, it will not be hidden again.
- Same Visibility Objects: Input child objects of the entity that will be activated or deactivated depending on the entity's visibility status. BEAWARE: Only child objects of the models are allowed in this array field and not the model parent itself! The field will only allow you to input direct child objects of the entity model anyway but it is important to keep this mind when designing the prefabs for your entities.
1.2.1 Building Prefab Specific
For buildings, you can add the Building Placer Fog Condition to the child object that has the Building Placer component to add a condition for placing buildings only in areas with a certain visibility.
- Minimum Fog Strength: If the fog strength/intensity is smaller than this value in an area then the building can be placed in that area.
Changelog
v2022.0.0
Release Date: 03/01/2022
Requirements
- RTS Engine 2022.0.0 or higher
Fog Of War 1.23 or higher
Changes
Initial Release
v2022.1.0
Release Date: 03/12/2022
Requirements
- RTS Engine 2022.1.0 or higher
Fog Of War 1.23 or higher
Changes
FIX minimap camera in demo scene setup to render fog of war exactly like the main camera.
- FIX UI elements to be visible over hidden areas in fog in the minimap camera (minimap icons and minimap cursor in the demo scene setup).
- FIX an issue where a faction entity model or any other same visibility object is not properly enabled/disabled when its fog visibility status changes when its active status is modified by other components other than the FogOfWarEntity (for example building health states affecting the building's model active status).
- FIX visibility post discovery (fully visible to local player) to preserve the state of the same visibility objects when going back to a fog area and not alter it even if other components in the entity affect its activity status until it is fully visible by the local player where the state of the same visibility objects is updated according to the changes it went through during the time it went back to the fog area.
- FIX rendering an entity hidden in fog to be not selectable even if it remains visible post discovery.
v2022.2.0
Release Date: 04/27/2022
Requirements
- RTS Engine 2022.2.0 or higher
Fog Of War 1.23 or higher
Changes
FIX a bug where new enemy buildings that have post discovery enabled are completely visible when placed in an area that is not completely hidden by the fog of war.
- FIX a bug where local player unit models are hidden when spawned.
v2022.3.1
Release Date: 12/25/2022
Requirements
- RTS Engine 2022.3.1 or higher
Fog Of War 1.23 or higher
Changes
FIX demo scene configurations.
v2023.0.2
Release Date 09/25/2023
Requirements
- RTS Engine 2023.0.2 or higher
Fog Of War 1.23 or higher
Changes
FIX a bug with the Animator controllers of units being deactivated when the units are hidden by fog which translates to the UnitMovement component not being able to complete an active movement, making the units stuck.
- FIX setting the initial visibility of entities in the fog of war.
- FIX an issue where an entity is hidden by fog and the player is able to right click it and target it with its currently selected entities.
- ADD a new demo scene with the same core demo game elements with FoW enabled.