So I've been trying to implement a health bar recently and I wanted it to follow my player objects (I have two because one of them is controlled with arrow keys and the other is controlled with w, a, s, and d).
The only problem is, I heard it was more efficient to have the visuals for the health bar in a separate class. I can't do that since I can't access my player x and y variables from another class since they aren't static (they can't be, or else I wouldn't be able to have more than 1 player object).
The reason I need to reference my player x and y variables is because I need my health bar to essentially follow my player. How would I go about doing that?
NOTE: I don't think showing code is completely necessary, since I only need the concept of how I would go about doing it. Thanks!