hi, i was doing the burgzergarcade tutorials and I ran in to this error: Assets/Scrips/Character Classes/ModifiedStat.cs(27,16): error CS0246: The type or namespace name `Attribute’ could not be found. Are you missing a using directive or an assembly reference?
Here is my code.
using System.Collections.Generic;
public class ModifiedStat : BaseStat {
private List _Mods;
private int _modValue;
public ModifiedStat(){
_Mods = new List();
_modValue = 0;
}
public void AddModifier(ModifyingAttribute mod){
_Mods.Add(mod);
}
private void CalulateModValue(){
_modValue = 0;
if( _Mods.Count > 0)
foreach( ModifyingAttribute att in _mods)
_modValue +=(int)(att.Attribute.AdjustedValue * att.ratio);
}
}
public struct ModifyingAttribute{
public Attribute attribute;
public float ratio;
}
Next time put your code in the right blocks for them.
[ CODE] [ /CODE] without the spaces.
In any case, it means that you are trying to create a class of type Attribute and Unity cannot find that class anywhere in your project, so it is giving you the error. Have you created a class called “Attribute”?
i have the same error, and i tried switching Attribute with attribute in all the places , and none of them worked. for example "_modValue += attr.attribute.AdjustedValue " with "public Attribute attribute; " or "_modValue += attr.Attribute.AdjustedValue " with "public attribute Attribute; " so what’s the problem? I have the same code as his. Loius I capitalized and didn’t work, and there are no ‘s’ .
You sure your script is named equal in the hierarchy and in the code? Cause I’d just support what’s already been said, for me the error is on line 1 of the attribute class… Again, if you changed the name of your classes you might want to look up if you changed the name in the project files too.
yep, they are. I have exactly the same code as in the tutorials. Although my error is slightly different: “error CS0246: The type or namespace name `ModifiedStat’ could not be found. Are you missing a using directive or an assembly reference?” and it appears twice, once in Skill, once in Vital.