Health as a Component or as a Variable on a Character BP?
In your opinions, is it best to have:
As variables on a character? Or as components on a character?
asked Sep 07 '16 at 01:18 PM in Blueprint Scripting
I know there are a couple ways to do what you're trying to do. There are tags that you can look into using. You could, for example, tag an actor as an Enemy, and make all actors tagged as enemies follow certain rules (like taking damage, having health, etc.) More relevant maybe using parent and child classes. For example, you can make a masterEnemyClass which comes with health, maxhealth, and dead variables already created. From that parent class you can create a child class that would inherit those same variables, but also allow for you to add more. For example, you could make a box class that has a cube for a static mesh. Then you could right-click that class, create child class, and make a red box class. The child inherits all the parents values, but can have its own additional values such as color on the static mesh that will not be applied to the parent
answered Sep 07 '16 at 04:37 PM
For something as generic as health, I'd put it in a component. The component could create damage numbers, handle elemental weaknesses, feed into a combat log, give points for kills, or perform any number of other useful health-related actions that you really shouldn't rewrite constantly.
Sure, you could put that functionality on a base class, but inheritance-based structures start making functionality flow upwards as your game expands until tons of actors that don't need the health code are running it and giving you a headache/slowing down your game.
answered Jun 18 '17 at 02:20 AM
I'm not sure why you would make them components. I use variables for those...variables in my game
answered Sep 07 '16 at 03:13 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here