So I’m trying to make a depleting health bar for a game. I’m trying a tween because the Repeat X Time extension screwed up the coding. There are two problems so far:
The tween goes on for longer than the set amount of time (10 seconds in this case).
The tween goes too fast at the start and then halfway through becomes very slow. I tried different tween types, but the same thing happens or the tween doesn’t even work.
I looked at the tween articles on the Gdevelop documentary and the easing functions, but they weren’t helpful.
Is there any way I can get the tween to flow consistently or scale the healthbar’s width another way?
I think it’s because you didn’t reset the timer. Once the timer goes above 1 second, the event keep triggering every game tic until you reset and/or stop the timer.
EDIT: Another thing, I didn’t think timers can go below 0. Maybe you can manually set them to start at a negative number? I can’t think of any other way for that condition to trigger
I think you went wrong route
Instead of tweening it how about add or subtract to bar width?
Imagine you have 100 HP
You got hit now you have 20 HP
You do not set bar to MaxBarWidth / MaxHP*CurrentHP
NO
How about
Bar Width is LESS THAN MaxBarWidth / MaxHP*CurrentHP
ADD 1 to Bar Width
AND
Bar Width is GRATER THAN MaxBarWidth / MaxHP*CurrentHP
SUBTRACT 1 to Bar Width
Where that 1 would determine speed in which it is adding or subtracting so bar growing shrinking
NOW there could be a problem of it constantly move since by adding some value you most likely won’t get it to perfect value of HP with perfect value of Width
You could simply do
If BarWidth is less than (and another event for greater than)
MaxBarWidth / MaxHP*CurrentHP+/-1
And now you use set bar width to MaxBarWidth / MaxHP*CurrentHP
Isn’t that basically the same thing as a tween? You can always interrupt a tween by using the same identifier so I’m not sure what the advantage is here (other than learning how to manually tween something :P)
Kinda sorta
Idea is not what it do
But how its done
This in my eyes is easier to understand and would not create logic issue like OP have with tweens
Less to understand = easier usage that is my personal view