The script below is giving me the following error message and I have no idea why:
“NullReferenceException: Object reference not set to an instance of an object
Characters.Start () (at Assets/Scripts/Character/Characters.cs:31)”
As far as I can see, everything is correct. Am I missing something?
public class Traits
{
public int id;
public string name;
public int strength;
public int agility;
public void characterData()
{
print("id: " + id + "Name: " + name + " Strength: " + strength + " Agiligty: " + agility);
}
}
void Start()
{
Traits[] character = new Traits[51];
for (int i = 1; i <= 50; i++)
{
character*.id = i;*
_ character*.name = “Jeff”;_
_ character.strength = 20;
character.agility = 20;
}*_
* for (int i = 1; i <=10; i++)*
* {*
_ character*.characterData();
}
}
}*_