How should I create/instantiate a skill/enemy/item

I was wondering what’s the correct way to create/instantiate skills, enemies and items with varying parameters.

In my case it would be creating a custom skill to be thrown on field based on player’s stats/skills. The skill has variables like damageFrom, damageTo, duration, delay and sometimes there can be a custom variable.

My current game is based on instantiating where it instantiates an empty object with my “BaseSkill” script. Then I was searching for a way to set these mentioned parameters and I ran into a way suggesting something like this:

skill1 = clonedPrefab.GetComponent<BaseSkill>().setDamage(1,3);
skill1 = clonedPrefab.GetComponent<Basekill>().setDuration(3);

… which looks a bit heavy, especially if there can be dozens of this same action happening at the same time. Should I go with objects as I’m working with C#, or something else? An example or link to a better way would be appreciated. Haven’t done objects with C# before

You want to create a reference and then set them via that reference. You don’t want to call GetComponent() for each one. Plus your syntax is wrong here (i.e. it would not compile).

BaseSkill skill1 = clonedPrefab.GetComponent< BaseSkill >();

Note by convention Methods and Classes start with a upper case letter. Variables start with a lower case letter. Nothing enforces this convention, but folks on the list expect it and therefore find code not written to this convention harder to read.