OnCollision2D Head Twist

Hello game devs, how is everyone this fine evening? :slight_smile:

I have been coding for the past three hours or so and using inheritance. Now, I have a Player (base class) and two derive classes. In the Player base I have a OnCollision2D function that is called when a player hits me. My health bar goes down by 2 (suppose to) and it shows in the text.

Now, with the function in the base class, it goes down by 6 (one base class and two derived make 3 x 2). This I don’t understand. The base class does not inherit from the derive classes. When I moved the function to a derive class, it worked perfectly. I was getting 98 health, 96, 94, etc. with each strike at me. But if the function remained in the base class I would get 94, 88, 82, etc. Can anyone explain this please?

I am using C# btw.

Thank you very much and have a wonderful evening. :slight_smile:

We would have to see a little code to help answer. What class is attached to your gameObject. Maybe post the code of the OnCollision2D in the derived class using code tags: