This is my code; Code (csharp): using System.Collections.Generic; public class ModifiedStat : BaseStat { private List<ModifyingAttribute> _mods; private int _modValue; 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) _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) { //error line Attribute = att; ratio = rat; } } This is the error i am getting: Assets/Scripts/Character Classes/ModifiedStat.cs(38,17): error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer Assets/Scripts/Character Classes/ModifiedStat.cs(37,61): error CS0171: Field `ModifyingAttribute.attribute' must be fully assigned before control leaves the constructor This is from thehttp://www.burgzergarcade.com/hack-slash-rpg-unity3d-game-engine-tutorial tutorials. I have absolutely no idea why this happens, as i have the exact same code as in the tutorial, and that runs fine. Any help appreciated.
Attribute = att; is error Assets/Scripts/Character Classes/ModifiedStat.cs(38,17): error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer ratio = rat; is error Assets/Scripts/Character Classes/ModifiedStat.cs(37,61): error CS0171: Field `ModifyingAttribute.attribute' must be fully assigned before control leaves the constructor
Look at these two lines: Code (csharp): public Attribute attribute; public float ratio; And then at these two lines: Code (csharp): Attribute = att; ratio = rat; In the above excerpt, the second line is correct, but the first line isn't. Do you see the difference between the two?
You sir, have helped me alot!!!! Thank you very much!!!!!! I did the same with a capital A instead of a small a.
So I keep getting this error for two different lines "Assets/Standard Assets/Scripts/General Scripts/ActivateTrigger.cs(43,58): error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer" targetGameObject.active () = true; targetGameObject.active () = false;