Unity : Array list bug

I’m creating an “RPG” project and i created this script but it doesn’t work i got this error:
ArgumentOutOfRangeException: index is less than 0 or more than or equals to the list count.

The script:

#pragma strict

function Start () {
    var Tom : Personnage = new Personnage();
}
class Character
{   
    var ID : Array = new Array("Human","20","false");
    function Start (){
        if(ID[2] == "false"){
            ID.Push("welcome.");
        }else{
            ID.Push("you're not allowed to enter HERE GET OUT!!!");
        }
    }
    function Character (){
       Debug.Log("You are an " + ID[0] + " you have " + ID[1] + " of health " + ID[3]);
    }
}

HELP!:frowning:

Move your array initialiser into the Start function or constructor

Also stop using arraylists
http://wiki.unity3d.com/index.php?title=Which_Kind_Of_Array_Or_Collection_Should_I_Use%3F

In this case you shouldn’t use any kind of array at all; your ID should be a class, not an array (where you’d have an enum with the race types, an int for the health, and a boolean).

–Eric

Thank you i’ll optimise my script! :sunglasses: