- Home /
how to change wind main property and transform of wind zone through c# script?
i have a wind zone in my scene. i want to access it's properties from a script attached to another game object. I want to change the position, direction and speed of the wind zone through script. I also have a sphere type game object. i want the sphere to move with a force in the direction according to the wind zone.
Answer by knowpixels · Feb 25, 2015 at 01:47 PM
Unity 3.x - 4.5 can not alter WindZone script properties at run time under JS/US strict typing (#pragma strict). If you want this to work use dynamic typing:
so remove #pragma strict from top of your JS/Unity script.
then reference the WindZone component exactly like this:
var wz = GetComponent("WindZone");
The Windzone script properties will then be available for you to alter at runtime in the var above named wz. Also you cant use typeof() inside GetComponent as the WindZone is a private class and not available through the Unity type system so you will get Unknown type error back if you do. The above work around may work for the other Private Class types in Unity. Hopefully someone will find this useful.