How to make Stamina Bar Fade Out when NOT Sprinting

So I’ve been trying to make the Stamina Bar fade out when not in use, buuuuuttt, when I try, it sometimes does work, while also overriding the sprint function, making the player unable to sprint. How do I make the Stamina Bar fade out when not in use, and fade back in when it IS in use without disabling sprinting?

Hi @Nocture2021

The stamina bar should be part of your hud. Or even a widget attached to your llayer i guess?

What you need inside your widget is to be able to read the current speed of your character then do a fade out based on that. So once the widget is runnibg do not unload it just fade it in and out based on the speed.

I am guessing you are trying to do this from your player and setting focus to it which is why you lose the controls.

Might have to be in the event tick of the widget to detect the player sprint. Unless u trigger an event from your player into the widget is another option.

A sugestion:

  • In the widget bP:
    ** Create an animation that interps the opacity from 0.0 → 1.0
    ** Create a function with a bool parameter that will handle the play / reverse of the animation. For example:

  • In your pawn/component: call fade function with parameter set to true on press and false on release and/or when stamina is full:

Should work like this:
StaminaFade

Hope it helps.

2 Likes

Exactly as i percieved it (well close enough) good stuff @pezzott1

what else you can do is:

fade in and out via an animation… right…

But… how to do that automatically?

create an event called “Trigger Stamina”. Inside ask, if the stamina is visible. If not, play the fade in animation.
If yes AND after animation playforward, add a “retriggerable delay”. lets say: 3 Seconds long.

after that delay play the fadeout animation.

You now call this event over and over again, as long as you need the stamina Bar to be visible. The clou is, that the retriggerable delay resets itself back to 0 everytime it gets called… and only plays the nodes after itself, if the delay reaches the duration.

means… if you stop sprinting/attacking…etc you stop calling the Trigger Stamina Event… and this will make the retriggerable delay to reach its duration and fade out the Bar

1 Like

From my project, here is similar to what pezzoti showed, except this isn’t using an animation, just setting opacity values directly:

I’m setting opacity for an image and also blur amount for a background blur at the same time


Runs from a timer

Awesome.

StaminaFadeAuto

2 Likes