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 Paul 6 · Mar 12, 2011 at 12:08 PM · errorsyntax-errorburgzergarcadecs0118

BurgZergArcade Script Error

I'm following the tutorials of a Hack and Slash game on BurgZertgArcade.com I thinks i've done everything correctly, but when I want to lay, an error appears on the console that says: Assets/Scripts/Player/CharacterClasses/ModifiedStat.cs(25,33): error CS0019: Operator +=' cannot be applied to operands of typeSystem.Collections.Generic.List' and `int'.

What can I do? What have I done wrong please help!

using System.Collections.Generic; public class ModifiedStat : BaseStat { private List<ModifyingAttribute> _mods; //A list of attributes taht modify the stat private int _modValue; //The amount added to the base value of the modifiers

 public ModifiedStat()
 {
     _mods = new List&lt;ModifyingAttribute&gt;();
     _modValue = 0;
 }

 public void AddModifier( ModifyingAttribute mod)
 {
      _mods.Add(mod);
 }

 private void CalculateModValue()
 {
     _modValue = 0;

     if(_mods.Count &gt; 0)
     {
         foreach(ModifyingAttribute att in _mods)
             _mods += (int)(att.attribute.AdjustedBaseValue * att.ratio);
     }


 }

 public new int AdjustedbaseValue
 {
     get{ return BaseValue + BuffValue + _modValue; }

 }

 public void Update()
 {
     CalculateModValue();
 }

}

public struct ModifyingAttribute { public Attribute attribute; public float ratio;

 public ModifyingAttribute(Attribute att, float rat)
 {
     attribute = att;
     ratio = rat;
 }

}

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Oliver J Rawlings · Mar 16, 2011 at 02:51 AM

and i think i just remebered somthing, - relook at you BaseStat.cs script - i re watched vids 11 - 20 and fix the error i hade with your line, - but a diffent error which i fixed by re typeing stuff in basestat. i know i got a site problem and inless i pase a screen shot into a image viewer i cant make shore i following the tutorial.

Comment
Add comment · Show 1 · 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
avatar image Paul 6 · Mar 16, 2011 at 12:35 PM 0
Share

Thanks, but I rewrite all the code and now it works perfectly:)

avatar image
0

Answer by Oliver J Rawlings · Mar 16, 2011 at 02:41 AM

funny enouth i working on a problem on the same scipt from the same tutorial, but have a

Assets/scripts/character Classes/ModifiedStat.cs(38,35): error CS0118: ModifyingAttribute.attribute' is afield' but a `type' was expected

error instead.

here is my script :-

using System.Collections.Generic;

public class ModifiedStat : BaseStat { public List<ModifyingAttribute> _mods; // a list of attributrsd that modify this stat public int _modValue; // the amout added to the baseValue from the modifyers.

 public ModifiedStat() {
     _mods = new List&lt;ModifyingAttribute&gt;();
     _modValue = 0;
 }

 public void AddModifier( ModifyingAttribute mod) {
     _mods.Add(mod);
 }

 public void CalculateModValue() {

     _modValue = 0;

     if(_mods.Count &gt; 0)
         foreach(ModifyingAttribute att in _mods)
         _modValue += (int)(att.attribute.AdjustedBaseValue * att.ratio);
 }

 public new int AdjustedBaseValue {
     get { return BaseValue + BuffValue + _modValue; }
 }

 public void Update() {
     CalculateModValue();
 }

}

public struct ModifyingAttribute { public Attribute attribute; public float ratio;

 public ModifyingAttribute(attribute att, float rat) {
     attribute = att;
     ratio = rat;
 }

}

Comment
Add comment · Show 2 · 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
avatar image Oliver J Rawlings · Mar 16, 2011 at 03:10 AM 0
Share

no matter i fixed the one error, my bad eye site - a "a" should of been "A", but now i got 6 new eorrros to solve

avatar image Oliver J Rawlings · Mar 16, 2011 at 03:17 AM 0
Share

Do not let a dislexic person, who is recovering from a Stress Attack dive into the deep end and do all the codeing for a main uni project....... ends in epic faill

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

No one has followed this question yet.

Related Questions

How do i rearrange this in C(sharp)? 0 Answers

Compile Errors for Script 1 Answer

Collision Detector script 1 Answer

I need help with an error 1 Answer

Limit rotation for a statue puzzle 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