- Home /
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 type
System.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<ModifyingAttribute>();
_modValue = 0;
}
public void AddModifier( ModifyingAttribute mod)
{
_mods.Add(mod);
}
private void CalculateModValue()
{
_modValue = 0;
if(_mods.Count > 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;
}
}
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.
Thanks, but I rewrite all the code and now it works perfectly:)
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 a
field' 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<ModifyingAttribute>();
_modValue = 0;
}
public void AddModifier( ModifyingAttribute mod) {
_mods.Add(mod);
}
public void CalculateModValue() {
_modValue = 0;
if(_mods.Count > 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;
}
}
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
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
![](https://koobas.hobune.stream/wayback/20220613112501im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
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