Search Unity

Create wind zone script (without using a WindZone object)

Discussion in 'Scripting' started by Karl_iyo, Mar 4, 2017.

  1. Karl_iyo

    Karl_iyo

    Joined:
    Feb 22, 2017
    Posts:
    9
    Hello everybody,

    The thing is, I want to create something like a wind zone to move trees, but I want to use this wind to move other things (whose parameters change using physics by script). I have tried with a normal windzone object, but I cannot get the wind force (there is no such a thing as a vector3 or vectorXD or whatever), so I can't use it. If I could get the force from the windzone object (in a vector), I could add this force in my physics engine.

    Any ideas??

    Many thanks!
     
  2. BTCallahan

    BTCallahan

    Joined:
    Jun 6, 2015
    Posts:
    71
    Try something like windzone.transform.foward, or if that doesn't give you what you're looking for, try windzone.transform.rotation.eulerAngles.
     
  3. Karl_iyo

    Karl_iyo

    Joined:
    Feb 22, 2017
    Posts:
    9
    None of them work...the wind changes but the value in the transforms remains the same...
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,443
  5. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,304
    Yeah. Reflection is the way I do it.

    Note that the windzone affects trees and particles.
    Terrain grass, on the other hand, is actually controlled using the terrain settings
     
  6. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    This is a shame. It would be so simple to make the current wind public in WindZone.
     
  7. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,304
    They have made it public. No reflection required anymore.
     
  8. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    We are indeed able to control the script by code now, but I was talking about the current wind itself. I still can't see any way of getting the wind force at some position, without ugly tricks.