Error cs1922

Hey everybody! I’m been working on BurgzergArcade’s Hack and Slash tutorial and now I’m receiving these errors

Assets/Scripts/Character Class/BaseCharacter.cs(115,82): error CS1922: A field or property ModifyingAttribute' cannot be initialized with a collection object initializer because type ModifyingAttribute’ does not implement `System.Collections.IEnumerable’ interface

I get 12 of these and they all go to my BaseCharacter.cs and the lines they go to are my my setupskillmodifiers,

here is the script if anyone for anyone who needs it to help find the error

using UnityEngine;
using System.Collections;
using System;  //added to access Enum class

public class BaseCharacter : MonoBehaviour {
private string _name;
private int _level;
private uint _freeExp;
	
	private Attribute[] _primaryAttribute;
	private	Vital[] _vital;
	private Skill[] _skill;
	
	public void Awake() {
		_name = string.Empty;
		_level = 0;
		_freeExp = 0;
		
	    _primaryAttribute = new Attribute[Enum.GetValues(typeof(AttributeName)).Length];
		_vital = new Vital[Enum.GetValues(typeof(VitalName)).Length];
		_skill = new Skill[Enum.GetValues(typeof(SkillName)).Length];
		
		SetupPrimaryAttributes();
		SetupVitals();
		SetupSkills();
	}
	
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	public string Name {
		get{ return _name;}
		set{ _name = value;}
	}
	public int Level {
		get{ return _level; }
		set{ _level = value; }
	}
	public uint FreeExp {
		get{ return _freeExp;}
		set{ _freeExp = value;}
	}
	
	public void AddExp(uint exp) {
		_freeExp += exp;
		
		CalculateLevel();
	}
	
	//take the adg of all the players skills and asign that as the palyer level
	public void CalculateLevel() {
	}
	
private void SetupPrimaryAttributes() {

for(int cnt = 0; cnt < _primaryAttribute.Length; cnt++) 

_primaryAttribute[cnt] = new Attribute();
		
}

private void SetupVitals() {
for(int cnt = 0; cnt < _vital.Length; cnt++) 
_vital[cnt] = new Vital();
				
		SetupVitalModifiers();
}
private void SetupSkills() {		
for(int cnt = 0; cnt < _skill.Length; cnt++)          
_skill[cnt] = new Skill();
		   
		   SetupSkillModifiers();

}
	
	public Attribute GetPrimaryAttribute(int index) {
		return _primaryAttribute[index];
	}
    public Vital GetVital(int index) {
		return _vital[index];
	}
	public Skill GetSkill(int index) {
		return _skill[index];
	}
	
	private  void SetupVitalModifiers() {
		//health 
		ModifyingAttribute health = new ModifyingAttribute();
        health.attribute = GetPrimaryAttribute((int)AttributeName.Might);
        health.ratio = 0.5f;
		
		GetVital((int)VitalName.Health).AddModifier(health);
		//stamina
		ModifyingAttribute Stamina = new ModifyingAttribute();
        Stamina.attribute = GetPrimaryAttribute((int)AttributeName.Agility);
        Stamina.ratio = 1;
		
		GetVital((int)VitalName.Stamina).AddModifier(Stamina);
		//mana
		ModifyingAttribute Mana = new ModifyingAttribute();
        Mana.attribute = GetPrimaryAttribute((int)AttributeName.Willpower);
        Mana.ratio = 1;
		
		GetVital((int)VitalName.Mana).AddModifier(Mana);
	}
	
	private void SetupSkillModifiers() {
		//melee offence
        GetSkill((int)SkillName.Melee_Offence).AddModifier(new ModifyingAttribute{GetPrimaryAttribute((int)AttributeName.Might), .33f});
		GetSkill((int)SkillName.Melee_Offence).AddModifier(new ModifyingAttribute{GetPrimaryAttribute((int)AttributeName.Agility), .33f});
		//melee defence
	    GetSkill((int)SkillName.Melee_Defence).AddModifier(new ModifyingAttribute{GetPrimaryAttribute((int)AttributeName.Might), .33f});
		GetSkill((int)SkillName.Melee_Defence).AddModifier(new ModifyingAttribute{GetPrimaryAttribute((int)AttributeName.Speed), .33f});

		//magic offence
		GetSkill((int)SkillName.Magic_Offence).AddModifier(new ModifyingAttribute{GetPrimaryAttribute((int)AttributeName.Willpower), .33f});
		GetSkill((int)SkillName.Magic_Offence).AddModifier(new ModifyingAttribute{GetPrimaryAttribute((int)AttributeName.Intelligence), .33f});

		//magic defence
		GetSkill((int)SkillName.Magic_Defence).AddModifier(new ModifyingAttribute{GetPrimaryAttribute((int)AttributeName.Concentration), .33f});
		GetSkill((int)SkillName.Magic_Defence).AddModifier(new ModifyingAttribute{GetPrimaryAttribute((int)AttributeName.Charisma), .33f});

		//ranged offence
		GetSkill((int)SkillName.Ranged_Offence).AddModifier(new ModifyingAttribute{GetPrimaryAttribute((int)AttributeName.Speed), .33f});
		GetSkill((int)SkillName.Ranged_Offence).AddModifier(new ModifyingAttribute{GetPrimaryAttribute((int)AttributeName.Agility), .33f});

		//ranged defence
		GetSkill((int)SkillName.Ranged_Defence).AddModifier(new ModifyingAttribute{GetPrimaryAttribute((int)AttributeName.Might), .33f});
		GetSkill((int)SkillName.Ranged_Defence).AddModifier(new ModifyingAttribute{GetPrimaryAttribute((int)AttributeName.Speed), .33f});

		
	}
	public void StatUpdate() {
		for(int cnt =0; cnt < _vital.Length; cnt++)
			_vital[cnt].Update();
		
        for(int cnt = 0;cnt < _skill.Length; cnt++)
			_skill[cnt].Update();
		
}
}

You can’t create ModifyingAttribute instance using syntax:

new ModifyingAttribute{GetPrimaryAttribute((int)AttributeName.Might), .33f}

Using {xxx, yyy} tells the compiler that some collection with two elements will be created. Instead you have to use:

new ModifyingAttribute
{
    attribute = GetPrimaryAttribute((int)AttributeName.Might),
    ratio = 0.33f
}

This way you create instance, with already initialized fields.

Btw - if you’re using System namespace, then watch out for potential problems, because there is Attribute type defined in this namespace.

ok I’m sorted on those errors but now I only have 3

Assets/Scripts/Character Class/BaseCharacter.cs(170,1): error CS1525: Unexpected symbol }', expecting )‘, or `,’

Assets/Scripts/Character Class/BaseCharacter.cs(172,61): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Assets/Scripts/Character Class/BaseCharacter.cs(172,68): error CS1525: Unexpected symbol )', expecting ;’

Here is the new code:

public class BaseCharacter : MonoBehaviour {
private string _name;
private int _level;
private uint _freeExp;
	
	private Attribute[] _primaryAttribute;
	private	Vital[] _vital;
	private Skill[] _skill;
	
	public void Awake() {
		_name = string.Empty;
		_level = 0;
		_freeExp = 0;
		
	    _primaryAttribute = new Attribute[Enum.GetValues(typeof(AttributeName)).Length];
		_vital = new Vital[Enum.GetValues(typeof(VitalName)).Length];
		_skill = new Skill[Enum.GetValues(typeof(SkillName)).Length];
		
		SetupPrimaryAttributes();
		SetupVitals();
		SetupSkills();
	}
	
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	public string Name {
		get{ return _name;}
		set{ _name = value;}
	}
	public int Level {
		get{ return _level; }
		set{ _level = value; }
	}
	public uint FreeExp {
		get{ return _freeExp;}
		set{ _freeExp = value;}
	}
	
	public void AddExp(uint exp) {
		_freeExp += exp;
		
		CalculateLevel();
	}
	
	//take the adg of all the players skills and asign that as the palyer level
	public void CalculateLevel() {
	}
	
private void SetupPrimaryAttributes() {

for(int cnt = 0; cnt < _primaryAttribute.Length; cnt++) 

_primaryAttribute[cnt] = new Attribute();
		
}

private void SetupVitals() {
for(int cnt = 0; cnt < _vital.Length; cnt++) 
_vital[cnt] = new Vital();
				
		SetupVitalModifiers();
}
private void SetupSkills() {		
for(int cnt = 0; cnt < _skill.Length; cnt++)          
_skill[cnt] = new Skill();
		   
		   SetupSkillModifiers();

}
	
	public Attribute GetPrimaryAttribute(int index) {
		return _primaryAttribute[index];
	}
    public Vital GetVital(int index) {
		return _vital[index];
	}
	public Skill GetSkill(int index) {
		return _skill[index];
	}
	
	private  void SetupVitalModifiers() {
		//health 
		ModifyingAttribute health = new ModifyingAttribute();
        health.attribute = GetPrimaryAttribute((int)AttributeName.Might);
        health.ratio = 0.5f;
		
		GetVital((int)VitalName.Health).AddModifier(health);
		//stamina
		ModifyingAttribute Stamina = new ModifyingAttribute();
        Stamina.attribute = GetPrimaryAttribute((int)AttributeName.Agility);
        Stamina.ratio = 1;
		
		GetVital((int)VitalName.Stamina).AddModifier(Stamina);
		//mana
		ModifyingAttribute Mana = new ModifyingAttribute();
        Mana.attribute = GetPrimaryAttribute((int)AttributeName.Willpower);
        Mana.ratio = 1;
		
		GetVital((int)VitalName.Mana).AddModifier(Mana);
	}
	
	private void SetupSkillModifiers() {
		//melee offence
       ((int)SkillName.Melee_Offence).AddModifier(new ModifyingAttribute{
			 attribute = GetPrimaryAttribute((int)AttributeName.Might),
             ratio = 0.33f
		}
			     ((int)SkillName.Melee_Offence).AddModifier(new ModifyingAttribute{
			 attribute = GetPrimaryAttribute((int)AttributeName.Agility),
             ratio = 0.33f
		}
		
		//melee defence
	     ((int)SkillName.Melee_Defence).AddModifier(new ModifyingAttribute{
			 attribute = GetPrimaryAttribute((int)AttributeName.Might),
             ratio = 0.33f
		}
			     ((int)SkillName.Melee_Defence).AddModifier(new ModifyingAttribute{
			 attribute = GetPrimaryAttribute((int)AttributeName.Speed),
             ratio = 0.33f
		}

		//magic offence
			     ((int)SkillName.Magic_Offence).AddModifier(new ModifyingAttribute{
			 attribute = GetPrimaryAttribute((int)AttributeName.Concentration),
             ratio = 0.33f
		}
	
		//magic defence
			     ((int)SkillName.Magic_Defence).AddModifier(new ModifyingAttribute{
			 attribute = GetPrimaryAttribute((int)AttributeName.Intelligence),
             ratio = 0.33f
		}
			     ((int)SkillName.Magic_Defence).AddModifier(new ModifyingAttribute{
			 attribute = GetPrimaryAttribute((int)AttributeName.Charisma),
             ratio = 0.33f
		}

		//ranged offence
			     ((int)SkillName.Ranged_Offence).AddModifier(new ModifyingAttribute{
			 attribute = GetPrimaryAttribute((int)AttributeName.Agility),
             ratio = 0.33f
		}
			     ((int)SkillName.Ranged_Offence).AddModifier(new ModifyingAttribute{
			 attribute = GetPrimaryAttribute((int)AttributeName.Agility),
             ratio = 0.33f
		}

		//ranged defence
			     ((int)SkillName.Ranged_Defence).AddModifier(new ModifyingAttribute{
			 attribute = GetPrimaryAttribute((int)AttributeName.Speed),
             ratio = 0.33f
		}
			     ((int)SkillName.Ranged_Defence).AddModifier(new ModifyingAttribute{
			 attribute = GetPrimaryAttribute((int)AttributeName.Agility),
             ratio = 0.33f
		}
	
}
	public void StatUpdate() {
			for(int cnt = 0; cnt < _vital.Length; cnt++)
			_vital[cnt].Update();
		
        for(int cnt = 0;cnt < _skill.Length; cnt++)
			_skill[cnt].Update();
		
		}
}

I’ve gone through that entire HackNSlash tut and Petey never leaves you with code with doesn’t compile due to syntax or other errors, so I would not advise changing anything since you don’t know what you are really changing. Put it back to how it was and look at his next video in the series, sometimes he hits his cutoff point in one vid but fixes it at the start of the next. Anything else is a typo somewhere.