Hey guys,
I am a total newby in Unity, so pls excuse my maybe “stupid” question, but I tried for hours and couldn’t find a solution.
I am working on a 2d Airhockey game with an AI enemy.
- I created a “Player” script, which has a “LivePointsCounter”-var.
- Then i created two other scripts, “HumanPlayer” and “AI”, both inherit from “Player” script. I connected those two scripts to a “HumanPlayer_obj” and a “Enemy_obj”.
Now I don’t know how to let every player, no matter if humanplayer or AI, know he has a livePointConter which will be displayed in the HUD and also he has to know his own goal, when the ball enters his goal he should lose livePoints.
I could do that if would code separately for “HumanPlayer_obj” and “Enemy_obj”, but I would like to not repeat my code.
I hope I managed to describe my problem
An example is very welcome.