I am not sure why I get a null reference error when I try to display the base value of a primary attribute on my character sheet.
I get the error from the setter / getter which looks like this:
// Primary Attributes
public Attribute GetPrimaryAttribute(int index) {
return _primaryAttributes[index];
}
The line that triggers the error is this:
// Set Strength
_attStrength.text = activePlayer.GetComponent<PlayerCharacter>().GetPrimaryAttribute(0).BaseValue.ToString();
The _attStrength variable is a UILabel that is initialized properly and verified using debugging. I can debug log the attribute
at that index when the application starts, so I’m not sure why it’s throwing a null reference error when I try to assign that
base value to the display text.
The only thing I can imagine is that the attributes are intialized on the BaseCharacter script from which the PlayerCharacter
script derives and maybe it’s not accessing them properly. However, intellisense works fine for the BaseValue when I type
that line, so I suspect that everything is linked up properly.
Any insight please?