Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

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:
    6,137
  5. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,022
    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:
    360
    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,022
    They have made it public. No reflection required anymore.
     
  8. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    360
    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.
     
unityunity