- Home /
NullReferenceException: Object reference not set to an instance of an object
Hello, I have been learning from a series of videos for a site called BurZergArcade a RPG game. And I have been following him step by a step, line by a line code, and now I am getting this message every time I run the scene and now the abilities and skills are not shown, only the Name which is shown:
NullReferenceException: Object reference not set to an instance of an object CharacterGenerator.Start () (at Assets/Scripts/Character Classes/CharacterGenerator.cs|72)
And here are the pictures of the error, one for when I run the scene, and the other is for where the error line is located:-
I have also uploaded the whole project in case you would like to look into it and check it yourself.
PLEASE anyone help me, I cannot continue watching the videos unless this error is solved. It ANNOYS me!!! http://www.mediafire.com/?accb6mm8d1nh3a3
Thanks.
Ok, those pictures are totally useless to me, since they are so low-quality you can't even read the line! Why can't you just post the line of code? It'd be much more readable. Screenshots are very rarely any use for solving these problems, because if you don't know what is causing it, you don't know what you need to show for people to be able to help!
In any case, a null reference exception happens when you try to access a variable which hasn't been assigned. $$anonymous$$ake sure that all the variables on that line are being assigned somewhere, and check to see if they're set up in the inspector if they're public.
Hello, It's not public I think, it's error giving me for the Name.. and when I double click on the error it sends me to line number 72 here check the picture:- It's a good quality this time, the last time it wasn't good because I used a tool to decrease the size of the picture and decreased its quality.
http://i1187.photobucket.com/albums/z393/BlackCitadel/Capture-24.jpg
No, I'm pretty sure it'd have to be _Toon which is null at this point. Try the line
Debug.Log(_Toon);
immediately before you would get the NullReference, and see what that shows.
Answer by aliakbo · Dec 02, 2011 at 12:34 AM
I found the problem!!
a copy paste error from previous videos!!
1) Go into BaseCharacter.cs. 2) Make sure your FOR loops are correct:
private void setupPrimaryAttribute()
for... _primaryAttribute[cnt] = new attribute();
..setupVitals()
for... _vital[cnt] = new vital();
..setupSkills()
for... _skill[cnt] = new skill();
Your answer

Follow this Question
Related Questions
Scripting - Refering Pre-Made Objects 1 Answer
Fading multiple objects 0 Answers
How to select objects sharing the same material 1 Answer
Material attaching 0 Answers