The type or namespace name `Attribute' could not be found.

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

Any help is appreciated.

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”?

Assuming Attribute is a valid type…

You’re problem is referencing it as Attribute rather than attribute.

Attribute is the type
attribute is the instance

ie. it should be…

foreach(ModifyingAttribute attr in _mods)
_modValue += attr.attribute.AdjustedValue

Ah, didn’t see that! You would be correct, JamesLeeNZ. My bad.

sorry, the error is here:

public struct ModifyingAttribute{
	public Attribute attribute;      / the error is on this line
	public float ratio;
}

I do have a class called attribute. I still don’t know that the problem is.

Here is the attribute script:

public class attributes : BaseStat {
	public void attribute(){
		ExpToLevel = 50;
		LevelModifier = 1.05f;
	}
}
	public enum AttributeName{
		Strength,
	    Agility,
	    Speed,
	    Concentration    
}

Thanks for your help.

attributes != attribute != Attribute

Remove the S and capitalize the A.

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.

Seriously, post all relevant classes using the [ code] tags

Sorry. I can’t believe it was a typo. After I checked it like, 14 times.

It’s fairly common actually. Make sure you revise your code thouroghly next time, though! You’ll save yourself a good deal of time!