Adding Fog of War to an Actor

Setup fog of war in Blueprints

Let's create a simple actor Blueprint. For this tutorial, lets call the newly created actor BP_SampleActor. Double click to open the full Blueprint Graph and switch to Event Graph. This is where we will add the Fog of war component at runtime.

The very first thing you need to do is to call Set Map Size because without this you'll end up seeing a full black screen no matter what. The value should be set based on the bounds of your play area. As a starting point, I'd recommend setting it to 10000 and tweak from there based on your requirement.

To add the node, right click on an empty are of your graph and search for Set Map Size and add it. Connect it to your Begin Play event like in the following screenshot.

Now search for Add Fog of War Component to Actor.

Since we want to add fog of war to this (BP_SampleActor) right click again on the graph and search for this or self and select Get a reference to self.

Once that is added, connect it to Target Actor pin. Then from the Return Value, drag a wire and select Promote to variable. Let's call the new variable Fog of War Component.

Now that we have created and assigned our component, lets tell the component to use a specific radius because without a radius it won't do anything. Right click on the graph and search for Set Fog Radius. Connect the previously created Fog of War Component to the Target Fog of War Component pin and set the New Radius to something like 3000.

Finally call Activate from the Fog of War Component. The finished graph should look like this.

Last updated