- Home /
Burgzerg arcade error with vital mods
Hi, I was following the burgzerg arcade tutorials fine since I know a bit about c# and I was able to solve all the issues, I typed the SetupVitalModifiers and no errors appeared at the console, but when I start the scene a Null Reference error appeared, don't know why this happens since I'm using the right variable. I'll paste the code here.
private void SetupVitalModifiers(){
//health
GetVital ((int)VitalName.Health).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.Constitution), .5f));
//mana
ModifyingAttribute manaMod = new ModifyingAttribute ();
manaMod.attribute = GetPrimaryAttribute ((int)AttributeName.Intellect);
manaMod.ratio = 1;
GetVital ((int)VitalName.Mana).AddModifier (manaMod); // AddModifier (manaMod) gives error
}
And I also have a minor issue that I can not understand, my skills and vitals increase by the number of skills//vitals in my lists, I mean, say that I have 9 skills, so with ratio of 1 the skill will increase by 9 points, and if I put the ratio to 0.1f, I will need 9 points to get 9 skill points but if I have 8 points of the attribute, the skill will have 0.
I suppose that the number of vitals//skills increases the AdjustedBaseValue somehow but I can't seem to find where I made the mistake, I've seen he vids 2 more times since the error but all seems to be just fine.
I've been trying to fix these errors for 2 days, looking forward somebody knows how to fix them.
Thx for the help.
EDIT : When I add a second skill modifier happens as well, might be a problem with the AddModifier list??
private List<ModifyingAttribute> _mods; // A list of Attributes that modfy this stat
private int _modValue; //ammount added to the baseValue from the modifiers
public ModifiedStat(){
_mods = new List<ModifyingAttribute> (2);
_modValue = 0;
}
public void AddModifier (ModifyingAttribute mod){
_mods.Add (mod);
}
private void CalculateModValue(){
_modValue = 0;
if (_mods.Count > 0)
foreach(ModifyingAttribute att in _mods)
_modValue += (int)(att.attribute.AdjustedBaseValue * att.ratio);
}
Your answer
Follow this Question
Related Questions
Timer Runtime Problem 2 Answers
Can anyone help ?? Timer and gui 0 Answers
pickup counter and timer help 0 Answers
How can I get an accurate gameObject count within a frame? 1 Answer