Download

How to add attributes to a character? (Attack, Defense, Speed, and Health Regen)

Hey guys,

I’m horribly new at Unreal Engine, and I’m having trouble soaking it in.

What would I need to do to add attributes like Attack, Defense, Speed, and Health Regen to a specific character in an RTS? I’ve tried looking for tutorials, but I can’t seem to find anything specific that explains this.

My thinking is that I should be able to create a base class with all the standard stats, so like:

Base “Soldier”:
Health: 100
Attack: 10
Defense: 10
Speed: 10
Health Regen: 10

Then I can create each other class of character with different variables of those stats. So like:

Berserker “Soldier”:
Health: 90
Attack: 15
Defense: 5
Speed: 15
Health Regen: 10

Tank “Soldier”:
Health: 100
Attack: 5
Defense: 15
Speed: 10
Health Regen: 5

Ranger “Solder”:
Health: 80
Attack: 10
Defense: 10
Speed: 15
Health Regen: 5

This is my first assignment in Unreal using Blueprints. Does anyone have the ability to help me? I appreciate any tips or areas you can point me to! Thank you.

You do it just the way you described! You know how to add variables to a blueprint, right? Just make a blueprint for your base soldier, give it variables for each of your attributes, and set their defaults. Then for each of your variant soldiers, create a new blueprint and choose the base soldier blueprint as its parent class. It will inherit the variables and their defaults, which you can then change, either in in the details panel, or click the little eye icon and check “show inherited variables”

1438ef3315ce37dd0b8db54aeedca751ed159c78.jpeg

Of course, what you actually do with those variables so they affect gameplay is a much bigger question . . .

for best results you want to make sure to set all the variables on construction how i have mine in constructions script i run a function called initialize, i have a “set” for all my variables plunged into each other. this ensures all your stats are set up when the character is spawned

Very true, and also you won’t have to change any variables that are the same as the “Base” (Parent) blueprint. You can create Child blueprints by right-clicking on a (soon-to-be Parent) blueprint and selecting Create Child Blueprint From…

Awesome, guys. I think I understand and can set this all up! Thank you for all of your help!

You are welcome.