Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Cinntaxx · Jan 01, 2015 at 01:44 PM · classesobject-reference-errorobject-reference-not-set

NullReferenceException: Object reference not set to an instance of an object

Have been trying to fix this error for hours now, and i'm at my wits end as to why this error is happening.

Here is the full error message;

NullReferenceException: Object reference not set to an instance of an object BaseCharacter.SetupVitalModifiers () (at Assets/Scripts/Character Classes/BaseCharacter.cs:105) BaseCharacter.SetupVitals () (at Assets/Scripts/Character Classes/BaseCharacter.cs:74) BaseCharacter.Awake () (at Assets/Scripts/Character Classes/BaseCharacter.cs:25)

CharacterGenerator.Start () (at Assets/Scripts/Character Classes/CharacterGenerator.cs:16)

I've been following along with a tutorial up on youtube (playlist here: https://www.youtube.com/playlist?annotation_id=annotation_801479&feature=iv&list=PLE5C2870574BF4B06&src_vid=wrsM7UOjLUw) and got up to EP 23 without any trouble, than this happened. I've scoured the internet for a solution, but nothing is working. Below are the two C# files the error mentions.

Base Character: http://pastebin.com/0sn6sKSe

Character Generator: http://pastebin.com/BX9qziKe

I've no idea what is actually going wrong and have gone back over the videos that cover the code in these files multiple times and just can't spot it. Placing down debug.log's didnt help too much.

Any help is greatly appreciated

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Landern · Jan 01, 2015 at 01:51 PM 0
Share

It appears that _primaryAttribute in BaseCharacter.cs has the correct length, but the object it is returning is null. Did you not setup each item in the Attribute Array. We can assume it's not an index problem since it was able to retrieve the null object from the array from the int value of the AttributeName.Concentration enum.

You can also see that the array is being initialized with a capacity in the Awake function, but where are the objects of type Attribute co$$anonymous$$g from that should be added to the array?

It should be happening in method SetupPrimaryAttributes(); that happens right below the array capacity set. Something is dorked up.

You may want to poke around the videos some more in that play list, feels like you're missing something.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Cinntaxx · Jan 01, 2015 at 08:14 PM

You put me on the right track there @Landern.

But it wasnt to do with _primaryAttribute or the attribute class.

It ended up being a problem in the AdjustBaseValue method in an entirely different class that isnt mentioned in the error log. Some debugging made me notice things weren't returning a second time during the calculation in the method. Something to the effect of the calculations not passing the float ratio only once before tripping up on itself.

Thanks for the help! :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

I'm confused 1 Answer

Accessing other script's variable into another script 0 Answers

Bug in Object reference ? 0 Answers

Object Reference Not Set Up As An Instance Of An Object 1 Answer

Getting an error trying to assign a value to an array of classes element 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges