Stamina bar randomly stops working

rather than worrying about dividing the value to get it to respond in a 0-1 range. Use a map range clamped node.

Then you can map the range of the value between 0 (or whatever minimum you want) and whatever you want the max to be and output it in the 0-1 range every time. If all the other logic is working then this should give you a solid result on the progress bar.

Hopefully this addresses the problem.

I made a stamina bar and system for one of my weapons. The system works fine, but the HUD progress bar is broken.

The weird thing, is that it worked for a few hours while I was making it, and then suddenly it stopped working. I kept quitting, playing, quitting, playing, launching standalone editors, and viewport launches, and it randomly works 1/100 tries. So strange that sometimes it just decides to work properly. If it worked once, why not stay that way? I didn’t change any settings, this just happened.

One weird thing to note, is that in most progress bar setups, I would be dividing stamina by the stamina max. This broke the progress bar even more. So because my stamina value is exactly 100, I only used stamina divided by 100, since it’s essentially the same thing. And it worked! But then it fails sometime later. It’s currently integers that get converted into floats. I tried doing the entire thing with only floats, but that didn’t work. It seemed to respond better using integer variables and then converted to floats at the end. Not sure why.

Here is the link to the game video that demonstrates what is wrong.

[Weapon Stamina Problem][1]

This didn’t work. The bar stays at 0. What are you plugging the set percent into? Is it coming of an Event tick? Or Event play? I’ve never tried setting up a progress bar inside the weapon blueprint I usually do it from within the widget. When I do it in the widget, the bar stays at 100% and doesn’t drop alt text

Oh wait lol. It just started AND stopped working again. I made breakfast, and in that amount of time, it stopped working again. It’s like I keep playing the game, and sometimes I get lucky and the progress bar moves.

Here is a link to a video to show what is happening. This happens with both the traditional progress bar setup, as well as the range clamp.

Look at the green bar in the bottom right.

WIP - Weapon Stamina Progress Bar

No it’s still not working. I tried starting immediately and waiting a few seconds and up to 30 seconds. I thought about hooking it up to an event tick, but the event tick does nothing.

Begin play can happen at different times for each time you load the game, see what happens if you press play and immediately start shooting as soon as possible. does it work more often?

also see what happens when you press play, wait a few seconds, then start shooting. does it work less often?

i made a quick little thing to show you how i would implement this logic if i were doing this.

In this case, it’s ok the use event tick because i’m using the StartRechargeStamina boolean to gate it off. Meaning, my tick logic only runs when my CurrentStamina falls below MaxStamina. Once my stamina is fully charged, it sets the boolean to false and stops running that part of the logic. Tick is ok to use if you gate off your logic

Good luck on your game :slight_smile:

see if there’s some way you could not use BeginPlay for your Stamina+

I tried using this logic, it looks like it makes sense but it conflicts with the fire system. I got this particular one from someone else which is overly complicated, which is why finding alternatives to this is hard. My event tick does nothing.

What is inside your update health bar function?

it would look something like this. the target would be your reference to your progress bar

337920-capture.png

So normally for weapons I set up all logic in the weapon actor itself and keep the HUD class purely for visual representation. I also only update when necessary by linking the HUD update to the fire weapon action. Something like this

So that when the weapon fires it reduces it’s ammo and then maps the range and using a reference I have to the HUD passes in the already clamped value to be updated there.

I know your logic for the weapon is a little different but for addressing the initial problem I can tell you that this way works flawlessly to update the HUD and hopefully it’s enough to help you identify where the problem lies if it’s only the progress bar that’s not updating.

I got it now.I just needed to see what the UpdateMyBar event was. And I also simplified the firing blueprint which may have also been causing problems. Thanks!