Author Topic: Recreate Fog Void with Fog of War  (Read 235 times)

faolad

  • Newbie
  • *
  • Posts: 5
    • View Profile
Recreate Fog Void with Fog of War
« on: November 07, 2020, 02:00:40 AM »
Hello, I want to recreate what Fog Void does but with Fog of War. Want to have a script that can put on objects and add this well defined radius that will follow them around in an all fog cover map, without making the fog go away after if the object is no longer there. Hope you can help me, Thanks!
« Last Edit: November 07, 2020, 02:04:31 AM by faolad »

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7103
    • View Profile
Re: Recreate Fog Void with Fog of War
« Reply #1 on: November 07, 2020, 05:39:03 PM »
Hi,

Take a look at the demo scene Fog of War, where the fog is cut when character moves through.

Basically the demo script is doing this:
Code
fog.SetFogOfWarAlpha(Camera.main.transform.position, 16, 0);

Which is setting the fog ttransparency at the camera position, with a radius of 16 and alpha of 0.

You could do something similar in a new script during Update() but instead of camera position simply pass transform.position, and attach that script to your unit.

For performance reason, do not call that method every frame - do that only if the unit has moved certain distance, for example 0.5 meters or so.

Also, you need to properly enable the fog of war in the inspector and assign the size for such fog of war effect in world space.

Hope this helps.