Health and Mana Interface/Framework

You’re looking for actor components. An instanced reusable chunk of logic that can be given to any actor.

Scrub through this to see if that’s what you need:

edit: you actually described the actor components quite precisely without knowing about them :slight_smile:

more info here:

And they can be used in BP, of course.

It’s always better to do some digging before diving in head first, sure!

Whenever I think about actor components, this thing comes to mind (AoWIII):

254346-capture.png

The abilities are in the list, there’s hundreds of them and pretty much any unit in the game can have any of them.
Modder’s wet dream.

Hello.

First of all, im not asking anyone how to help me make logic that i will use for my hp/mana system, but how to build framework, or interface, which will have some inputs and than outputs.

Instead of making Health and Mana system for every Actor or Pawn i have in my game, is there a way to create Interface or Framework for health and mana, so i will just have to override certain variables?

How would i like it to look is something like a class function with “setters” as input and “getters” as output.

In hidden layer(update), that class function should use a overrided Event Tick from setter Actor/Pawn/Character… and than plug that in Sequence, and every tick should check for some variables, for example there would be a boolean variable to check wether hp/mana is full/empty.

Also,if i think twice, it does not even need to override Event Tick from setter Actor/Pawn/Character…It can be called like a standard blueprint node, for example “Set Actor Location”.

Consider this:

ThirdPersonCharacter_Blueprint → Event Graph → Event Tick (gets plugged in HP_MANA_SYSTEM function) and in hidden layer(update) that gets pluged in Sequence which checks every second certain conditions and acts appropriatly.

This would be easy way i guess. One less input.

In C++ that would be like a some base class, and every entity(Actor for example) will inherit that base class and have its own “Constructor” or “Setters” i would prefer for its own Hp/Mana/ManaRegen/Full/Empty…

And since i dont know anything about UE4-s C++, could that be done trought blueprints, instead of creating a new C++ class?

Alright, thank you very much for fast answer.
Il check out for other solutions too, if someone answers.

Yes, that wont be a problem i guess.
I think that if i know how to build a hp_mana_system i will know also how to build something like that on a picture. I think thats classic user interface made of widget with lots of buttons and some text, or atleast thast how would i create it.

The user interface is not what I meant at all, that’s a different story altogether. What I meant is using actor components in a modular way - the way they were designed to be.

A health component would have (simplified here):

  • min / current / max health vars
  • methods for adding / subtracting / boosting
  • optional bleeding functionality here if so desired
  • making the owner invincible
  • this component is perfect for handling Dying / Resurrecting
  • a component can be in charge of its own widget - when added to a Pawn, it hooks itself up to the player’s UI

Depending on what the scale of the project is and the complexity you envisioned, you may not need to use this approach at all. You can easily make a Pawn class with Health/Mana functionality and simply extend it so every child inherits shared methods and variables (this can be combined with actor components for the best result, though!).

Sprinkle it with some Interface magic and you’ll have a potent and flexible system. It just takes time to wrap one’s head around it.

The YT link I posted demonstrates the basics well. I miss Zak. :expressionless:

Good luck!

Okay man. Thank you very much for your answers. Il try everything and will see what fits my needs… :slight_smile: