I have asked A LOT of people, but no one can seem to help. I am sooo stuck it hurts my head, so please help me here. I need to fix my object reference not set to an instance of an object code… Here is one code( the (>) is where the problem shows):
private void SetupSkillModifiers() {
//Melee Offence
ModifyingAttribute MeleeOffenceModifier1 = new ModifyingAttribute();
ModifyingAttribute MeleeOffenceModifier2 = new ModifyingAttribute();
MeleeOffenceModifier1.attribute = GetPrimaryAttribute((int)AttributeName.Might);
MeleeOffenceModifier1.ratio = .33f;
MeleeOffenceModifier2.attribute = GetPrimaryAttribute((int)AttributeName.Nimbleness);
MeleeOffenceModifier2.ratio = .33f;
(>)GetSkill((int)SkillName.Melee_Offence).AddModifier(MeleeOffenceModifier1);
GetSkill((int)SkillName.Melee_Offence).AddModifier(MeleeOffenceModifier2);
as well as this section:
private void DisplaySkills() {
for(int cnt = 0; cnt < Enum.GetValues(typeof(SkillName)).Length; cnt++) {
GUI.Label(new Rect(250, 40 + (cnt * 25), 100, 25), ((SkillName)cnt).ToString());
GUI.Label(new Rect(355, 40 + (cnt * 25), 30, 25), _toon.GetSkill(cnt).AdjustedBaseValue.ToString());
}
I think this code might be the source of the problem I am having:
using UnityEngine;
using System.Collections;
using System; //added to access Enum Class
public class BaseCharacter : MonoBehaviour {
private string _name;
private int _level;
private uint _freeExp;
private Attribute[] _primaryAttribute;
private Vital[] _vital;
private Skill[] _skill;
public void Awake() {
_name = string.Empty;
_level = 0;
_freeExp = 0;
_primaryAttribute = new Attribute[Enum.GetValues(typeof(AttributeName)).Length];
_vital = new Vital[Enum.GetValues(typeof(VitalName)).Length];
_skill = new Skill[Enum.GetValues(typeof(SkillName)).Length];
And Finally I added this code, which holds the SkillName variable. I believe it has some part in the problem. So heres the code:
public class Skill : ModifiedStat {
private bool _known;
public Skill() {
_known = false;
ExpToLevel = 25;
LevelModifier = 1.15f;
}
public bool Known {
get{ return _known; }
set{ _known = value; }
}
}
public enum SkillName {
Melee_Offence,
Melee_Defence,
Ranged_Offence,
Ranged_Defence,
Magic_Offence,
Magic_Defence
}
I hope all of these codes will help you guys help me… So if you don’t think this is enough I have other codes that might help.