Hi, I’m trying to use inheritance on my c# classes for strategy game units. So basically a class called Robot will inherit from another class called Unit. I want both of them to do operations in their Update methods but I guess the Robot’s Update just overrides Unit’s Update. How can I handle this situation?
put a base.Update(); at the top of the inherited classes Update
Gah, I was trying super.Update() and was disappointed when it didn’t work out. But ofc this isn’t java but c#
Thanks anyway dreamora.
edit: this raised a side question. when I called for base.Update() it said unreachable due to protection level so I had to put protected void Update() but isn’t void Update() supposted to imply protected on normal condition? Or is it always private?
if you just write >> void Update(), it will be always private , same goes for variable if you write just them like
float something
int something
which is same as write
private float something etc…
if you want them “protected” then you have to specify it.