Hi, i have a problem with creating an array of class objects.
I get the warning
You are trying to create a MonoBehaviour using the ‘new’ keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all
UnityEngine.MonoBehaviour:.ctor()
Weaponsscript:.ctor(Int32, Int32, String, Int32, Int32)
Weaponsscript:Start() (at Assets/scripts/Weaponsscript.cs:43)
lines(43 and near) are:
public void Start () {
weapons = new Weaponsscript[] { // 43 line
new Weaponsscript(1, 1, "item1", 50, 500),
new Weaponsscript(2, 0, "item2", 60, 750),
new Weaponsscript(3, 0, "item3", 75, 1000),
};
}
Construcor:
public Weaponsscript(int type, int lvl, string name, int dmg, int costgrowth)
Array declaration
Weaponsscript[] weapons;
Thanks to all who answer.