I need help in creating a system where my player uses stamina for running, jumping and attacking. So far I have only created a blueprint where it uses stamina for sprint.
Hey @PhantomBladeX8!
Looks like you’ve got the basics down here, so all you have to do is something very similar.
When jumping, before all other code: get stamina, check if Stamina is > the stamina you need, and if that returns true (branch) do as you did with the others where you GET stamina, subtract the amount you want, and SET stamina from that number. After that, do the rest of the jumping code.
You can do the same for your attacks, or anything else.
Hope that helps!
I did tried that but what happens is I set to reduce stamina by 10 but it keeps on reducing the stamina during the jump until it is left with 10 stamina and then the regeneration does not work. Could you please assist.
Have you tried a simple on IA_Jump event checking and using the stamina? Attacking should be pretty easy and similar to this if your using GAS, on ability activated run something like this. Double check in the IA action for your jump that it is firing only once
I think you overengineered it a bit…
Can you try this setup of 3 functions and tell me if it works for you:
Where
Stamina Change
is how your stamina is regenerating or draining (depending on the sign) per second.
The benefits are: No timers, no delays, Stamina is calculated only when needed.
The caveats are: You have to go through GetStamina() to have it properly calculated before using it.
Edit: I wasn’t sure for the ContiniousStaminaChange
weather you want your Change per Second to modify the Stamina Change or override it. It is currently overriding it but you can modify instead.