Hi guys, I’ve got a little problem with custom classes and inheritance.
I’ve got an empty base class, for example
class A{
public void Acoolfunction(){
//do nothing
}
}
but now I’ve made some other clases
that inheritate from this class. Lets give it an other example:
class B : A{
public void Acoolfunction(){
Debug.Log("Hello World");
}
}
class C : A{
public void Acoolfunction(){
Debug.Log("Cya World");
}
}
Now we come to the tricky part:
I need a list that can contain both classes, B and C. So I created an array of A and added B’s and C’s to it. My problem is, that when I try to call the Acoolfunction of my listed classes, he will allways call the function in A, not the functions from B and C that overwrited it.
So I know the problem, but if I remember right it should have worked that way
How can I get it to actually call the right method and not the parent typ method?
Thanks for any help.