[C#]how to use child class type in parent class method.

Hello, my problem is this here -

onUse Method in ITEMCREATOR.class

	public int onUse(ITEMCREATOR modifier){
		if(modifier.GetType() == typeof(POTION)){
			if(modifier._TYPEID == 1){
				return (GainHealth(modifier));
				return 0;
			Debug.Log("this item has no external function");
			return 0;

GainHealth method in ITEMCREATOR.class

	public int GainHealth(POTION modifier){
		int changed = 0;
		PlayerStats.HEALTH += PlayerStats.MAX_HEALTH / modifier._MODIFIER;
		return PlayerStats.HEALTH;

I have a ITEMCREATOR.class, where this onUse() is located.

and i have a POTION class that is derived from my ITEMCREATOR.class.

This of course gives me a error, because _MODIFIER is a part of my POTION class, not my ITEMCREATOR class.

I know the problem, i just dont know how to fix it, and if there even is a way to make it work.

Any help is greatly appreciated.

Also, if my grammar seems a bit messy or flauded, it’s because English is not my primary language. Hope you will understand :slight_smile:

The best way to handle this is to make the onUse function virtual and override in the potion class. Here are some references for you to read through that will explain it a lot better than I would be able to: