Search Unity

Radar Weather Map

Discussion in 'Scripting' started by LMan, Aug 20, 2018.

  1. LMan

    LMan

    Joined:
    Jun 1, 2013
    Posts:
    493


    Working on a game where the player's view is a radar map. It's an incomplete information strategy game- The idea is that a player can "hide" units by having them travel with the weather.

    I'm brainstorming to see how I could generate a weather map to a render texture.

    • The weather map has to change over time, moving according to some wind data. clouds form and dissipate.
    • Ideally, it would be nice if I had enough control to create large weather events, like a hurricane.

    I figured the map itself would be a 2D byte array in the shape of the screen, which I would then populate using some noise + rules about where weather would generate. But I'm not sure how I would then figure out if a cloud was "gathering" or "fading."
     
    Rioneer likes this.
  2. FlashMuller

    FlashMuller

    Joined:
    Sep 25, 2013
    Posts:
    451
    I would probably define a "Front" Gameobject hat holds several "Cells" and defines the overall movement. Each child-cell would have a semi-transparent grayscale texture - just like a heightmap. Rotation, Scale and Position would create random patterns, the overlay changing intensities. The overall situation could be rendered to a texture that would then be the basis of you 2d array.
    Fading and Gathering would just be controlled be the alpha of the cells and handeled by the front, which could react to additional mechanics like generation and fading zones.
     
  3. Fido789

    Fido789

    Joined:
    Feb 26, 2013
    Posts:
    343
    1. Use perlin noise to generate the weather data for each cell
    2. Have some treshold variable. All cells with value greater than treshold will be clouds, the other ones will be clean weather.
    3. Move the treshold value up and down to make your clouds gather or fade.
    4. Optionally, combine threshold with another perlin noise map to make some clouds gather and some fade.
     
    bienbientaco likes this.
  4. LMan

    LMan

    Joined:
    Jun 1, 2013
    Posts:
    493
    This is good stuff, I think I'm almost ready to start throwing stuff together.

    After doing some research, I've got some more detail about how clouds are modeled.

    • Weather Manager
      • Map Resolution- WxH how many "cells" to divide the play area into.
      • TimeStep- how often to evaluate.
      • Weather Profile- governs the range of values injected into the map.
      • Map- 2D array of Class "WeatherCell"
      • Average WeatherCell- representation of averages across the map.
    • WeatherCell
      • Surface Temperature - heat energy going into the cell.
      • Wind Vector - direction and strength of transfer between cells
      • Saturation - how much water in the cell
      • Pressure - derived from temp and saturation, differences in pressure between cells gives wind.
      • Lapse rate - rate at which dry air cools. This is our "cloud threshold." from this we derive atmosphere stability- below this we get clouds. far below this (rate 'wet' air cools) we get storms. This is usually modeled as a curve, but I think I can get away with a flat percentage.
    I think this simulation should be pretty easy to manage- I should keep track of cells "pushed" out of the map, and use a profile to govern cells that get added. I can add a set of warmer cells to make a warm front, Or cold cells for a cold front.

    The interesting thing is going to be weather events- where I'll have to engineer the values a bit to trigger hurricane conditions, then govern them to maintain the event for however long I'll want it to stick around.
     
    bienbientaco likes this.