Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How to implement fog of war

Discussion in 'Scripting' started by armorhide406, Jul 10, 2020.

  1. armorhide406

    armorhide406

    Joined:
    Mar 18, 2016
    Posts:
    16
    Trying to build a game, and first I need to make a representative minimap. The only way I know of is to have a camera faced top down, but I want to be able to build one similar to other games where it isn't displaying the actual game.

    Add to that a fog of war effect, I'm assuming I have my camera, map graphic as a target and maybe another "fog" layer where I can change the opacity/alpha channel, but I want to be able to do it in a small radius as classic "fog of war" in many games.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,723
    All of this is possible by giving your top down camera a different culling mask than your main camera: https://docs.unity3d.com/ScriptReference/Camera-cullingMask.html

    You can even child big red and blue spheres or whatever you want to your GameObjects that are in a layer visible to the minimap camera only.

    Here's a tutorial:

     
  3. CyrinGames

    CyrinGames

    Joined:
    Aug 16, 2020
    Posts:
    3
    Did you ever figure this out? I found there's a way using a plane with a black material between the map camera and the world and make pixels transparent in a radius around the player, but I only know of Get/SetPixels and I've been warned away from these apparently-performance-heavy functions. Everywhere I go it's just more people throwing these basic mini-map tutorials at me, which are the first things Google shows me.
     
  4. armorhide406

    armorhide406

    Joined:
    Mar 18, 2016
    Posts:
    16
    I used this tutorial but then we ended up scrapping the fog of war effect