This is extremly usefull for TopDown-View games, like PocketCrusades.
The first thing you need to do is set up the KGFMapSystem. If you do not know how to do so, take a look here: KGF-Support.
Now, when you have everything set up, be sure to check the Fog Of War option in the settings.
Thats how it looks for me:
You can change the resolution depending on the size of your world.
Now, create a new Script called FowCreator.cs! Thats where we will instantiate layers that are visible for the "Game"- Camera. These will get the same texture assigned as the FogOfWar plane for the minimap.
Here's the script:
Thanks to Brainswitch Machina and Alexandre Ouellet for pointing out some improvements!
using UnityEngine;
using System.Collections;
public class FowCreator : MonoBehaviour {
private GameObject[] layers;
public float[] heights;
private bool isCreated = false;
// Use this for initialization
void DoCreate () {
isCreated = true;
int layers_to_use = heights.Length;
layers = new GameObject[layers_to_use];
GameObject pre = GameObject.Find("fog_of_war");
Vector3 apos = pre.transform.position;
//apos.y = heights[0];
//pre.transform.position = apos;
//pre.layer = 0;
for(int i = 0; i < layers_to_use; i++)
{
layers[i] = (GameObject)GameObject.Instantiate(pre);
apos = layers[i].transform.position;
apos.y = heights[i];
layers[i].transform.position = apos;
layers[i].layer = 11;
}
}
void Awake() {
StartCoroutine(findLayer());
}
IEnumerator findLayer()
{
GameObject ag = GameObject.Find("fog_of_war");
while(ag == null)
{
//Dont call find with string too often, this will slow the rest down
yield return new WaitForSeconds(0.1f);
ag = GameObject.Find("fog_of_war");
}
DoCreate();
}
}
Now, in the editor assign some testing values. Depending on your "world" you'll need different ones.
Choose how many layers you want. The higher, the better it looks, however, at great computing costs. Since I develop for mobile devices, I just use one. The element values themselves are the height of the layers. The highest should be higher than anything visible for the camera.
That's it. Tomorrow I'll make a brief demo on the Warriors, be sure to check it out.
Thanks for reading.