I have a parent class Unit, and child classes melee unit/ranged unit. The parent class holds uninitialized fields such as health, damage, etc. the child class sets the values of these fields in an Awake function.
In another script, I have a Start method:
void Start(){
gridX=5;
gridY=5;
for (int i = 0; i<(gridY*gridX);i++){
allies.Add(new GameObject());
}
AddUnits();
SetupGrid();
}
AddUnits looks like this:
void AddUnits(){
allies[0] = (GameObject) Resources.Load ("Units/melee unit");
allies[1] = (GameObject) Resources.Load ("Units/ranged unit);
number = 2;
}
The resources loaded are prefab gameobjects containing their respective melee unit or ranged unit script (both which derives from base class Unit)However, when I check the health value of the gameobjects allies, they're always 0. Can anyone help me figure out why?