(SOLVED)Circular Stamina Bar

How do I Create A Circular Stamina Bar System in GDevelop Like The One In The Legend Of Zelda: BotW and TotK?

Hello! I’m trying to find a solution on how to create a circular stamina bar like the one in The Legend of Zelda: Breath of the Wild and Tears of the Kingdom.

The Expected Result:

ezgif-1909c2ed12f7b92d

The bar should only appear when you click w, s, a, d (forward TOPDOWN movement) and disappear when it is tweened (linear movement) to full value, when you stop clicking any of the buttons (w, s, a, d). Also, as you can see in the video below, the tip of the bar (when reducing) is red (smoothly tweeting in and out of use with linear movement).

My Code:

My Result:

clideo_editor_ca8fff649aa047f98e4429d12e022b52

I have already tried myself, but I could not figure out a way to do it.

I needed to recreate your events to better understand the issue. I think it’s the line that’s adding an object when there’s zero objects. Yes, it has a trigger once but when the object is deleted the trigger once gets reset and the cycle starts again since I’m assuming the object variable’s default value is zero.

You might need to change stamina back to false or use an additional variable or condition.

Maybe, instead of tweening the value of the object that gets created, you could tween a scene variable or a player object variable. That way the stamina value wouldn’t be reset to zero everytime the shape painter was deleted and added to the scene.

Maybe if the events were split up so you could use a trigger once with the stamina is true event.

Stamina = true
Trigger once
… Number of objects is zero

Then put the other events in another group.

1 Like

okay, thanks :)! Ill see if that fixes it

Unfortunately, your idea did not work, but you gave me an idea, which did improve it to some extent.

Tween should not play each frame
More sense would be to show/hide bar than create/delete it

And now you just need to manage variables

1 Like

Thanks, this helped a lot!

1 Like

There are just two more questions I’d like to ask. At the end of the stamina refill animation, the red and the background circle seem to disappear a bit slower than the green stamina wheel. Also, I would like the player to stop moving when the stamina has run out. How would I do this?

clideo_editor_7d710096753447ddb144c7c93d307d5e

1 Like

A - is responsible for how fast opacity change
B - is changing opacity for dark green bar and red bar

You could add another variable in A for example instead of - 5 you could go with - 10 or even more for it to disappear faster

And this is your stamina

But its in revers
0 means you are full on stamina
360 means you are out of stamina

So you would just check if stamina = 360 then disable topdown behavior
Where if its not equal to 360 then enable topdown behavior

BUT i guess you would need to add there some timer
So for example when you use up all your stamina
To wait like 1 or 3 secs before it starts to refill

1 Like

Thanks once more for the help :slight_smile:

2 Likes

I’ve tried doing this, but it doesn’t seem to work…

1 Like

You have no action that set stamina to true

What you are doing makes no sense

You should use that variable to block movement and not to kick in stamina variable

For example HERE


You should make parent event with condition stamina variable is false
Actually that is stupid

Like i told you FAILVARIABLE is your stamina
When its 0 it means you did not used up any
When its 360 you used up all

Kinda like going in revers think of it does not indicate how much stamina is left
BUT how much of stamina you used up

So when its 360 it means you used up ALL your stamina so you should not be able to move

SOOOOO

In that condition i mentioned above
Put
INVERTRTED FailVariable equal to 360

BUT like i told you you should add there some timer
Cause it should drop down as soon as you stop moving
So well you will see what i mean once you try it without timer

There should be a timer that starts when stamina reaches 360
AND only when you are not moving and that timer does not exist you should start regaining stamina
(You should delete that timer as soon as it reaches some value for example 1 sec or maybe half? your choice)

BUUUUT that is still stupid
Cause you will be immediately able to move as soon as you regain even 1 stamina and then get stuck as soon as you gonna try to move

That is why more sense would be simply to set player max speed to something LOW when you reached max stamina usage

Have walk and run modes (speeds)
Where NOT MOVING would regain stamina fast
Walking would regain stamina slowly
Running would drain stamina

Actually i never played that zelda you mentioned
But isnt it exactly like that in that game?

1 Like

Thank you, it is now working 100% the way I want it :smiley: !!!

2 Likes

Sorry again, but how would you slow the refill and the use of stamina? I have tried multiplying and dividing. and adding and subtracting to the Fail Variable, but it only changes the starting position.

Generally this is speed
In each of expression you see + or - some value
It literally mean how fast

2 Likes

Thanks for the help :+1:

1 Like