It is not possible to inherit from more than one C # class, so I came here for suggestions for my problem.
I'm building a little game using Unity. In Unity, the game objects ( GameObject
) inherit from a superclass called MonoBehaviour
, as is the case with my Player
class, and as is the case with my Enemy
class.
Both Player
and Enemy
have the possibility to choose a target on the screen and execute Attack()
. However, in the case of player
, its target can be either Enemy
or Player
. In innocence I quickly created a Entidade
class, put a RecebeAtaque(Attack a)
method on it, and made Player
and Enemy
inherit from Entidade
. After that, I made the method Attack
get a Entidade
parameter.
However, Player
and Enemy
already inherit from Monobehaviour
, so this was not possible. I need them to inherit from MonoBehaviour
, because this super class gives me ways to manipulate GameObject
in the game scene.
How could I implement this?