How to increase max hp when players add skill points

I have a mini game where players earn skill points and can add it to increase their shield or their hp. I can’t figure out how to get those skill points to apply the character and increase the max hp and shield value.

I have some code in place, but I have no idea if it is working or how to tell its working. Everything in the comments box is what a programmer I hired did (convert a card game to give skill points) but he didn’t tell me how to apply to the character (in this case, a car)

Any help would be greatly appreciated!

You’ll need some kind of formula to determine how much HP you want to give. Once you have that You’ll just need to set you characters max health on game startup, respawn, level up, etc. I’m assuming he set up a variable for max health that is.

You must create a function to be called in SuperCar_Blueprint. In this function, you will change the value of the variable which increases the Shield’s HP.
After you cast to the SuperCar, you must call this function, which (after a check if the player has points to spend, if you haven’t done in your logic before) will increase the Shield/Player’s HP, which is inside of SuperCar.
You can do the same to the character’s HP, just creating another specific function for the HP’s value.

I would recommend you to see some tutorials about Cast and see how they call functions using that, or check here Casting in Blueprints | Unreal Engine Documentation

But if you still having difficulties we are here again :slight_smile:

I forgot to mention that he also did the attached code, but I think it just has to do with turning the points to text. And actually, I set up the main hp code.

Is this the right way to do a function?

This function returns the current value of the shield in a Text.

Yes, this function is bind to the current BP Class you’ve created, so every Class has it’s own functions. To call it from another class, use Casting.

Actually when you call this function it increases all Points’ current value to your HP’s (you’ll spend all points in HP)… If you want to spend one by one, you’ll have to add 1 to your HP and decrease 1 to your Points.

Please bare with me as I’m not a programmer. This is what I did this time. I wrote something to give me the value of the hp in the hud so unless that is wrong its not working yet

Simple Point System:

First, you need to create the variables you’ll need.

At least, those two in the print (Points and Health)
I’ve chosen Integer type, feel free to change to Float if you wish.

After that, create those 3 functions:

  • Receive Points;
  • Add Health;
  • Give One Point.

In each, follow the prints below:

Don’t forget to Add Inputs to the functions in the “Details” window, usually on the right of the editor (“Receive Points” and “Add Health” will need), and to create an Output for “Give one Point” function, as you see in the “Return node” at the end.

And for last, follow this on your Event Graph:
(Those keybinds were just to trigger the functions, you will need to trigger them following the logic of your skill point system)

Note that i’ve put a condition before giving health points that checks if the “Points” variable is above zero. If True, it will trigger the “True” nodes sequence. If False (Points = 0 or less), it will print the message “Not Enough Points” in the screen.

***Each point in Health given equals to 100 health points unit. (See my post above)

Follow the same logic in your shield, creating an individual function to it.

Good luck!

The function “receive points” would be called in the mini game right?

You should call whenever you want to increase the Points variable of your class.

If it’s the case only in your mini-game, there’s no point calling it outside :slight_smile:

(Sorry for the delay!)

No worries for the delay, I’m quite busy with other freelance projects myself. I appreciate the help you’ve been giving me!

Well, it keeps saying not enough points, so I’m guessing its not receiving the points variable from the mini game

Probably, so you need to check in your mini-game if its calling the function in the situations you want.

First to do:
The Points Given is getting a value from some target, so check if this value is higher than zero, try calling a Print String after your “Receive Points” connecting the same “Points” node in the string value.

Still doesn’t work:
All the time you reward the player/actor with points, you should call the Receive Points function.
The only time you call the Receive points function (as I see in the picture) is when you set shield and points to a target, maybe it’s missing another situation to call it: when you reward the player/actor.

Try checking if your mini-game allows you to call the receive points function in the situations you want…

Sorry if I’m getting you confused, I’m trying to communicate my ideas to a non-programmer, like you said before

I get what you are saying. I feel as if I’m missing a link of how to get the “set points” connected to “points given”

https://www.unrealengine.com/marketplace/ultimate-attributes-and-stats-component - the best I’ve found. I have almost the same code, but attributes is increasing not as they should.

Gbr update: GBR - YOUR CODE WORKING PERFECTLY … I’ve checked once again, both types multiplayer and singleplayer. Thanks