Hello,
I’m trying to call a function from a class of an object. I have the Object but no clue to access the right Component.
A little Example:
public class Heal : Effect {
public void ApplyEffect(GameObject user, int amount) {
print("Healing " + user.name + " for " + amount);
}
}
Thats the Method I want to Call from this:
public class ItemPotion : Item {
public GameObject _effect;
public int _value;
public void Use(GameObject user) {
Type component = ???
component.ApplyEffect(user, 25);
}
}
I cant call it with GetComponent() because it should work with any other class as well. When I call the Method, I know the Method is there because every class from Effect has this one, but I dont know the concrete Name of the Class.
Hope you can Help.