Hello,
I have four missiles on a launcher,
Each press on the fire button toggles another missile
Everything works, except error line 16, Array index is out of range.
var missile :GameObject[];
var CurrentMissile : int ;
function Start()
{
CurrentMissile = 0;
}
function Update ()
{
if (Input.GetButtonDown("Fire3"))
{
missile[CurrentMissile].GetComponentInChildren(Homing).Fire();
CurrentMissile ++;
}
}
This means that the variable CurrentMissile is a number that is outside the range of the array.
Does the array have anything in it? I dont see them assigned in the code so have you assigned them in the editor? Right now I see an empty, unititlised array and you are trying to access the first element in it.
Remember an array is a list of a fixed size.
Also this is a common programming question, and in no way specific to Unity so you can find a ton of info on this on the internet. Is this your first time programming?