📈Optimization

Tips to improve performance

Static Fog

In an RTS or top down game there are two types of units. One that moves and one that doesn't move. Like buildings which does not need to constantly update the fog of war because they don't move and they should typically only add fog of war effect when they are spawned and removed from world.

In this plugin, you can mark fog of war component as static (not in the sense of mobility) at runtime anytime you need, using the Set Fog as Static function. For example using our previous BP_SampleActor, you can set the component as static since it doesn't move.

In C++, you can make a dummy function like this and call the static function directly.

#include "AgoraFogOfWarStatics.h"
...
void MySampleActor::MarkAsStatic(bool bNewStatic)
{
    UAgoraFogOfWarStatics::SetFogAsStatic(TargetFogComponent, bNewStatic);
}

If you get linker error, make sure to see this page.

As mentioned before, this node (or code) can be called on fog of war component anytime you need. If you were making an RTS game and you move a pawn from point A to point B, you can Set Fog as Static to false when the unit starts moving and Set Fog as Static to true when it stops moving.

Tick Rate

Updating the tick rate also helps in performance. If you want to have smooth fog of war movement, then setting it to Medium is good enough. If you are ok with not so accurate fog of war update, then set it to Very Slow. It can be done at runtime using Update Fog Tick Rate node.

You can also set this option directly in Project Settings -> Agora Fog Of War Settings instead of setting at runtime.

To set the tick rate at runtime using C++, simply call the static function from anywhere at anytime you need.

#include "AgoraFogOfWarStatics.h"
...
void MySampleActor::ChangeTickRate(EAgoraFogOfWarTickRate NewTickRate)
{
    UAgoraFogOfWarStatics::UpdateFogTickRate(this, NewTickRate);
}

If you get linker error, make sure to see this page.

Last updated