Download

Sprint/Stamina bar

hi guys so i have my sprint mechanics set up and now im implementing my stamina system, but just wondering if there is a better way than using event tick??

here is my set up which works

8257b3618cf3eb26ce66bbd8a5c669ae0a4035a3.png

so basically (every frame) it checks to see if the boolean isSprinting is true or false. If it is true then we decrease the stamina by 1.0

like i said this all works but is there an easier/ better way ? thanks

“–” is already set your variable for “your variable - 1”

timeline or combination of event tick + world delta sec, so your resource cost is not framerate dependent.

i dont understand???

You will be fine using Event Tick. What you should do instead though is subtract delta seconds, rather than subtracting 1, otherwise players will be able to have their stamina last longer with a lower framerate.

is there not a better way though than event tick because i dont need to check everyframe i only need the check when the sprint button is held down ?

Delta Time is seconds passed in game. Event tick is called every frame, which will vary based on game play and the users computer specs.
I also would not use timelines at all.

You could put it in the movement input. For example, if shift is down and you are updating movement in the forward direction, then drain stamina. This is a little more complex and shouldn’t make a big difference in performance. Event tick would be fine.

Another way is to put a delay before the stamina drain in the event tick. You will set the amount of stamina drained after each delay tho. This is more optimal.