Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Pathfinder · Aug 18, 2011 at 02:45 PM · windzone

How can I change WindZone settings with a script?

I've been having a lot of fun experimenting with WindZones and trees I've made in Unity's Tree Creator. It's amazing the amount of realism you can get with just the right settings.

What I'd like to do next is make the settings in a WindZone in my scene change via a script. I'm using UniSky and want my WindZone settings to change based on the different weather. Stormy?...trees are whipping in the wind. Clear?...trees are completely still.

I looked in the scripting reference and reference manual but couldn't find anything that explains how to do this. Is it possible?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Waz · Aug 18, 2011 at 05:07 PM 0
Share

Seems this bug still exists. Pretty poor, since Unity themselves thought it was available right back in 3.0.0.

http://forum.unity3d.com/threads/60593-Access-Terrain-Wind-Setting-and-Wind-Zone-in-Unity3D-3.0.02f

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by knowpixels · Feb 25, 2015 at 02:21 PM

You dont need to hack around with reflections if you understand Unity typing paradigms.

The WindZone DataType is private in Unity as of 3.x - this is still true as of 4.5.x This means you cannot access its properties using strict typing (#pragma strict) and typeof(). This is because WindZone is not strictly a type (public data type), so if you try GetComponent(WindZone) or GetComponent(typeof(WindZone)) you will quite rightly receive an unknown data type error message from Unity Console. All you have to do is switch to dynamic typing, it is this easy in JS/US:

  1. Remove #pragma strict from the top of your script.

  2. Change any usage instance of GetComponent(WindZone) or GetComponent(typeof(WindZone)) to GetComponent("WindZone"); (Include speech marks!) and remove any variable type declarations from WindZone usages.

So instead of:

 #pragma strict
 var wz:WindZone = GetComponent(WindZone);

Your script should look like:

 //#pragma strict
 var wz = GetComponent("WindZone");

Now the unknown type error in Unity console will be gone and your script has access to WindZone script properties through the var called "wz" you can now do:

 wz.windMain = 1;
 wz.windTurbulence = 1.2;
 wz.windPulseMagnitude= 0.6;
 wz.windPulseFrequency= 0.2;


Now you have full run time visibility and control of your in game blustery goodness.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Waz · Aug 18, 2011 at 05:12 PM

One option that I have used (in a WebPlayer where reflection hacks are forbidden) is to have an animation that changes the values. You can then play (or more likely, Sample, though I didn't need that much precision in my case) the animation to change the values.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by StefanoCecere · Jul 24, 2012 at 04:38 AM

i too was looking for Wind Zone class/references... there aren't yet! :(

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by getyour411 · Apr 24, 2014 at 11:02 PM

One change you can do, assuming WindZone is marked as Direction, is access the WindZone's transform via script and rotate it. I tested that by adding a simple JS that I got somewhere to my WindZone's gameobject and watched my WindZone rotate (I only did Y) and my TerrainTrees react to that change realtime.

 var rotationSpeedX:float=0;
 var rotationSpeedY:float=5;
 var rotationSpeedZ:float=0;
 var local:boolean=true;
 private var rotationVector:Vector3=Vector3(rotationSpeedX,rotationSpeedY,rotationSpeedZ);
 
 function Update () {
    
 if (local==true) transform.Rotate(Vector3(rotationSpeedX,rotationSpeedY,rotationSpeedZ)*Time.deltaTime);
 if (local==false) transform.Rotate(Vector3(rotationSpeedX,rotationSpeedY,rotationSpeedZ)*Time.deltaTime, Space.World);
 
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to link a Main Camera via script and scripting for WindZone 0 Answers

how to change wind main property and transform of wind zone through c# script? 1 Answer

Accessing 'Wind Main' on windzone objects thru script 0 Answers

Script Help 3D touch animation 1 Answer

How to attach a script to a static Tree Prefab? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges