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 Viurtun · Jul 03, 2014 at 12:41 PM · counternull reference exceptionburgzergarcade

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);
     }




Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

How can I avoid null point exception and count clones? My counter only counts the original ball but not the clones. Help? 0 Answers

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


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