- Home /
Question by
Maltus · Aug 13, 2010 at 02:10 AM ·
arraywheelcollider
applying a value to all items in an array[]
I have two seperate arrays of wheelcolliders that i would like to apply a mass of 3.0 to each item I would like to do this at function Start() if it is possible.
P.S.I am using UnityJavaScript Thank you for any aid in this subject.
Comment
3 is actually an var wheelmass : float; inside the script TrackController.js
and the arrays are Lefttrack Array and Righttrack Array
Best Answer
Answer by Julian-Glenn · Aug 13, 2010 at 03:47 AM
Untested code as I don't have Unity with me but something like this should work:
function LoopThroughWheelColliders() {
wheelColliders = FindObjectsOfType(WheelCollider);
for (var wheelCol : WheelCollider in wheelColliders) {
wheelCol.mass = 3.0;
}
}
I was able to use that code for something I was stuck on, Thanks
Thanks I appreciate the simplicity of it. Though I still would like to set individual properties of items in specific arrays[]
Your answer
![](https://koobas.hobune.stream/wayback/20220613071119im_/https://answers.unity.com/themes/thub/images/avi.jpg)