Health System

Is there a reason why this is a monobehaviour? I am not sure if I am missing something, but I have seen interfaces used for similar things before, would that be appropriate here?

Thanks

I don’t think there’s a need for an interface in this case. The health system manages the health and for this game there is no different way that it would need to do that. You certainly could use interfaces, but there would be no reason for it, really.

While you can use interfaces, ultimately you are still going to need some component to track the current health of each Unit. The most efficient way to accomplish this is to simply create a Health component. I can’t think of any reason that we would have different health components in this context that would require an interface, as a Health component generally has a fairly simple job… keep track of the current health and notify/handle when that character’s health goes below zero (dies).

In fact, I tend to use the same boilerplate Health component in all of my games. All that may differ is how the starting health is determined, whether set in the inspector or determined by a class/level system (like in an RPG). Everything else is generally the same.

3 Likes

Ok, that makes sense.
Thank you!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms