I am making a game of tanks, which therefore involves a lot of wheels. Rather than make a new script for each vehicle I want to make just one flexible script.

I have gotten as far as making a bulletin array, but I don’t know how to change the torque of wheels when they are inside an array.

var wheelsleft:WheelCollider[];

function Start(){
}

function Update () {}

To change the values within an array, you must “iterate” through it (or over it - both seem to be correct terms).

A common way to do this is with a “for” loop. You can also do a “foreach” loop.

	// This will print the Game Object name of everything in the array:
	var myArray : GameObject [];
	for (var i : int = 0; i < myArray.Length; i++) {
		Debug.Log (myArray*.gameObject.name);*
  •   }*
    
  •   // You can include many operations within this for loop, including tests:*
    
  •   for (var i : int = 0; i < myArray.Length; i++) {*
    

_ if (myArray == someValue) {_
_ myArray = someNewValue;
* }
}
// This will go through all of the contents of an array and do something to it.
// In this case it will turn all of the red lights off:
var myLights : Light ;
foreach (light : Light in myLights) {
if (light.color == Color.red) {
light.enabled = false;
}
}*
In your case, you will need to run through all of your wheels with a for or foreach loop and do something to it…_

The only note I would throw out there is: Do you need to work all the wheels? Can you “drive” your tanks in a different manner, and then simply run the wheels as a visual effect?