So the Player Class would potentially be refactored into something like the PlayerController Class.
So putting it all together the new classes would work like this:
- Health → responsible for health
– HealthUI → subs to Health component Action Event
- Gun → responsible for gun related actions reloading, firing, and ammo
– GunUI → subs to Gun component Action Event
- Player → holds reference to Health and Gun components and handles player interaction with them.
The reason I brought up naming is because that specific Player Class is probably the most common poorly named Class in a beginner project, so I think it’s a very great example given by the instructor. I am almost certain that I have a couple early projects that just have a Player Class and GameController Class where searching for any specific functionality is rough or requires collapsing multiple methods and reading lines of comment text to navigate. (Might go back and try to clean up those projects after I finish this course as practice.)
These classes essentially only functioned as containers to hold functionality that should of been broken up into individual classes but at the time I was more concerned with knocking off the programming dust and making something that worked. Now I’m really trying to knock the dust off of the more refined parts of coding with things like single responsibility and basically everything covered in this course.
So far it’s been really informative and refreshing topics and concepts I vaguely remember from school, I just need more clarification on the best Unity approaches as well and lucky for me GameDev has a great community for support.
Thanks again for the detailed example.