Search Unity

Realistic Wind

Discussion in 'Physics' started by radkosuper, May 28, 2019.

  1. radkosuper

    radkosuper

    Joined:
    May 28, 2019
    Posts:
    2
    Hello!

    Im making a simple paragliding game, but im kind of stuck.
    I want to add wind, witch works fine exept the wind can pass trough my terrain..
    Normaly the wind would be deflected off of the hills upward giving the paraglider lift but i have no clue how to get this type of behaviour.

    Here is a picture of what i mean


    I have no clue how to do this please help!
    Any kind of help is appreciated!
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Simply raycast down whenever you need to know the height and angle of anything you want. Let us know if more is needed from that.
     
  3. radkosuper

    radkosuper

    Joined:
    May 28, 2019
    Posts:
    2
    Hi, thanks for your reply but im looking for a way to make the wind behave as described not the glider.
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    The "wind" is a force, you *have* to do this.

    When modelling forces like wind it's a force acting on a rigidbody, wind does not exist in Unity as you would expect it. So the applied force thats "wind" needs to factor in 2 things:

    1. elevation of ground below
    2. the angle of the ground below

    Then you orient the "wind" force based on ground slope, and change it's strength based on the elevation, 2 things which are covered by RaycastHit which returns the position and the normal of the surface it hit.

    Once you have the normal, you can quickly use it to determine what the angle is.

    To rotate the wind vector is then a trivial operation, but that's how things happen in physics in games or simulations. There's no actual "wind" feature in Unity that will do what you ask, so you will need to do your own via forces.
     
  5. tjmaul

    tjmaul

    Joined:
    Aug 29, 2018
    Posts:
    467
    Hey radkosuper,

    Nice challenge you have there! I guess you’d like to model a terrain, set a general wind direction and let an algorithm take care of the rest?

    I’d go about this like this:
    Offline:
    - Create a greyscale Image of your terrain. - Apply a low pass filter (blur) to said image so smooth out small artifacts in your landscape.
    - Create a normal map from the grayscale image

    Ingame:
    - Sample the normal at the Position your paraglider is located.
    - go on like hippocoder described :)

    Another idea is to explicitly create wind field volumes. I’d create a box with a trigger collider in the area where you’d like to have the base wind direction changed and superpose a wind vector on the base wind.

    How to actually implement that in your plane model, I don’t know.

    Let us know if it works!