- Home /
Question is off-topic or not relevant
What is wrong with the script and how can i solve it?
PlayerPrefs.SetInt(((VitalName)cnt).ToString() +" - Base Value" ,pcClass.GetVital(cnt).BaseValue); I have asked many people and it only occurs on Windows 7 64-bits
The error I get When I press Create Button is:
NullReferenceException: Object reference not set to an instance of an object GameSettings.SaveCharacterData () (at Assets/Standard Assets/C# scripts/Character statistics/GameSettings.cs:32) CharacterGenerator.DisplayCreateButton () (at Assets/Standard Assets/C# scripts/Character statistics/CharacterGenerator.cs:148) CharacterGenerator.OnGUI () (at Assets/Standard Assets/C# scripts/Character statistics/CharacterGenerator.cs:56)
I think it has something to do with the vital script it is:
public class Vital : ModifiedStat { private int _curValue;
public Vital(){
_curValue = 0;
ExpToLevel = 40;
LevelModifier = 1.1f;
}
public int CurValue{
get{
if(_curValue > AddjustedBaseValue)
_curValue = AddjustedBaseValue;
return _curValue;
}
set{_curValue = value;}
}
}
public enum VitalName {
Energy,
Mana,
Health
}
Both the scripts are in C# Can someone help me? please
@saurabhn04, Your question (as it appears now) is not appropriate for UnityAnswers. It has the following problems:
Question is not of interest to other Unity users. Questions on UnityAnswers should be broadly applicable beyond your specific project.
Question is a 'fix my code for me' or 'fix my scene for me' question. UnityAnswers (UA) is not Quality Assurance (QA) - it is up to you to write and bugfix your own code.
Please search for 'null reference exception' to learn what this error means, and please search this answers site for other users with similar questions, to see how they solved it and apply the same solution to your problem.
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Unity 3d(Space) Questions 1 Answer
Scene changing 1 Answer