Fog of War API

advanced scripting

World Map Globe Edition · Scripting Support (C#)

Class: All members on this page belong to WorldMapGlobe (namespace WPM). Access via WorldMapGlobe.instance.

Fog of War Properties

bool showFogOfWar { get; set; }

Enable or disable the fog of war layer.

int fogOfWarResolution { get; set; }

Resolution of the fog texture (higher = more detail, more memory).

float fogOfWarAlpha { get; set; }

Global fog transparency (0 = invisible, 1 = fully opaque).

float fogOfWarElevation { get; set; }

Height of the fog layer above the globe surface.

float fogOfWarNoise { get; set; }

Noise amount for fog edges (0-1).

Color fogOfWarColor1 { get; set; }

Primary fog color.

Color fogOfWarColor2 { get; set; }

Secondary fog color (creates a gradient effect).

Fog of War Methods

void SetFogOfWarAlpha(float alpha)

Sets the fog alpha globally (0 = clear all fog, 1 = full fog everywhere).

void SetFogOfWarAlpha(Vector3 spherePos, float alpha, float radius, float strength)

Sets fog alpha in a circular area around a sphere position. Use alpha=0 to reveal, alpha=1 to conceal.

spherePos
Center of the area on the sphere.
alpha
Target fog alpha (0 = clear, 1 = foggy).
radius
Radius of the area.
strength
How strongly the alpha is applied (0-1).
void SetFogOfWarAlpha(Country country, float alpha, float strength)

Sets fog alpha for an entire country.

void SetFogOfWarAlpha(Province province, float alpha, float strength)

Sets fog alpha for a province.

void SetFogOfWarAlpha(Region region, float alpha, float strength)

Sets fog alpha for a specific region.

void SetFogOfWarAlpha(Cell cell, float alpha, float radius, float strength)

Sets fog alpha for a hex grid cell area.

Code Example

using UnityEngine;
using WPM;

public class FogOfWarExample : MonoBehaviour {
    void Start() {
        WorldMapGlobe map = WorldMapGlobe.instance;

        // Enable fog of war
        map.showFogOfWar = true;
        map.fogOfWarAlpha = 0.85f;
        map.fogOfWarColor1 = Color.black;
        map.fogOfWarNoise = 0.3f;

        // Start with everything hidden
        map.SetFogOfWarAlpha(1f);

        // Reveal Spain
        Country spain = map.GetCountry("Spain");
        map.SetFogOfWarAlpha(spain, 0f, 1f);

        // Reveal a circular area around a position
        Vector3 madrid = Conversion.GetSpherePointFromLatLon(40.4168f, -3.7038f);
        map.SetFogOfWarAlpha(madrid, 0f, 0.05f, 1f);
    }
}
Was this page helpful?