"Am I so cruel that I enjoy teasing you with the idea of using a tween and then pulling the rug out from under you? Absolutely but that's not relevant here." that had me dying
Thank you so much for the clear and succinct tutorial. I love the high speed so it's easy to ignore the parts I know and pause on the parts I need to pay attention. Liked and Subscribed!
Thank you for all the videos you upload on your channel! I'm so glad I could find this channel, considering it's more of less underrated. I also love how you manage to keep videos always under 10-15 minutes! Great job, keep up the good work! :D
Also, there is also a repeated-icon based health meter, much like Legend of Zelda. This is done by using an array and a loop to draw each icon. For fractional values, (fraction of an icon), you can do repeated subtraction (until the remaining units is 0 or negative) or division with remainder to determine the full and fractional icons. For example, each heart has 4 units, and you have 2 full hearts + 1 quarter. Therefore you have 9HP: 9 - 4 = 5 (first heart is 4/4), use the difference for the next heart... 5 - 4 = 1 (second heart is also 4/4), take the difference for the next heart... 1 - 4 = -3 (went in the negatives! So take that remaining value to be this third heart (1/4)). So if you subtract and doesn't result negative, then it is a full heart. If you subtract something bigger, then the minuend is the value of the last heart that isn't empty.
Also, if you're planning to add numbers display for HP (including displaying damage numbers), make sure you have them as int and not floats. Even if you make the display use a round-to-whole number function, it may be possible the player notice that the damage value is 1-unit off (inconsistent damage). And to display it as a bar, you have to multiply before you divide so that you don't end up with a bar only displaying 0% (if HP is 0 or less than max) or 100% (max), like [HP*100/MaxHP] instead of [HP/MaxHP*100] because each mathematical operation (specifically division in this case) does the rounding towards zero in the int world. You may lose some pixel precision, however it is very possible to create rounded-division by checking the remainder being greater than half the divisor, then increase the quotient by 1, otherwise leave the quotient be.
Gret tutorial, but I have one question, I'm trying to connect the health bar to the player while it's in a Canvas Layer UI. Do you know how to do this?
Great video but i have a question this might sound stupid but i am new to godot how to i apply this to enemies and how do i make it when the player collides with something he looses health i already did the coding from the tutorial but i dont know how to apply it
You need to call the _on_health_updated() method on the healthbar. You can do so via a signal if your character emits one when their health is updated.
well done, that's a really good tutorial, but I have one question, I didn't understand what "amount" is for in the _on_Health_update, and which value I should put in there. Again, thank you very much for making these great tutorials!
Hey there! Regarding the health bar keeping the bright color and not returning due to the tween "getting stuck"... I've found that Tweens seem to "forget" their interpolate_property instructions
I keep running into an error "Invalid set index 'Value' (on base: 'Nil') with value of type 'float'" here's the section that if giving the problem onready var health_bar = $HealthBar func reciving_stats(HP): health_bar.value = HP Any solutions or Ideas?
Awesome tutorial man! This really helped me with some logic on a UI element I'm adding to my game. Question though, how would you make the health bar that's hovering over the player not affected by things like a canvas modulate? Because I had a day and night system in my game and i don't want my UI's that move with my player to be affected by the coloration of the day. When I try adding these UI's to a different canvas layer node they no longer follow the player and now follow the camera so I'm a bit stuck now. I feel like adding the UI to a new CanvasLayer is the way to go, but I'm not sure how to glue that canvas layer on top of the player properly I guess
That's a good question that I never considered actually. My first though would be to much like you said, add it to a layer above. You might be able to anchor it to the character via RemoteTransform2D. The healthbar might need a Node2D base for that. I don't know that a RemoteTransform2d can position a Control node, let alone properly.
@@GameEndeavor Good idea! I've never used the RemoteTransform2D node before but I'll try experimenting with that. But yeah you're right it doesn't work with Control nodes so I'll need to change the base to a Node2D
I'm having an issue where the healthbar just stays at one health an never changes ;-; im using this code ---extends Control onready var health_bar = $Healthbar func _on_health_updated(health, amount): health_bar.value = health func _on_max_health_updated(max_health): health_bar.max_value = max_health---
You have to tell the player to update the health on the bar, you can use (player script) get_tree().call_group("health bar group name","health updating function")
i was able to connect the player's healthbar, but i had to remove the "amount" from _on_health_update and because of that, now the _flash_damage() function is unused. i'm still not being able to connect it with the GUI healthbar. nice tutorials btw i love them :) keep it up
Hello :) first of all thanks for the tutorial. I have a question in the _on_health_updated(health) method , on the line " health_over.value = health" I get this error Invalid set index 'value' (on base : Color') with value of type 'int' . Do you have any idea why my TextureProgress value doesn't get updated?
@@alexandracherciu Howdy. :) Thank you for watching it. Looks like you might've misassigned your health_over as a color. The defining of it should look something like this `onready var health_over = $HealthOver`. Your solution is just as valid though. I tend to cache all of my used nodes into variables. Your fix just skips that step. :)
What would be the best way to connect the "pulse" signal to the Player? Like if the HealthBar is in the UI, where should connect() be called? For example, in a node that is a parent of both the Player and UI, or in the Player's script by passing the HealthBar to the Player somehow? Thank you! PS. I love how you weave in little jokes during busy work moments like just creating a node so I can laugh without missing anything.
Good question. There are various ways you could do this. A lot of times when I create a level, I won't directly instance the player in the scene from the inspector. Instead I will create a spawn point and in the level code I'll have it spawn the character at that location. During that process I would connect the signals there. I prefer this method since it allows for such flexabilities. For example this would also come in handy if you allowed the player to select from a roster of characters before entering the level. Alternatively if you know that the level is going to be the current scene, then you could cache it in the level script, then in the player's _ready() method you could call `get_tree.current_scene.health_bar.connect()`. However (without extra checks) doing that would lock you into that setup and require that the player always be instanced with the level as the current scene. Glad you like the jokes. :) I love hearing that people are enjoying them.
It's just a signal connect. You can either do it through the inspector, or through the code ie connect("health_updated", $HealthBar, "_on_health_updated")
@@GameEndeavor Sorry but don't get it. Is there a reference to some other video? How to calculate percentages (where is the clamp function or some other way of measuring values between max and min!?)
@@petarkosovic6455 There is no method, you don't need to calculate percentages. ProgressBars have a max_value and a value property. They do the work for you. But calculating percentage is just `value / float(max_value)` (* 100 to make it a true percentage, but that's rarely useful)
@@petarkosovic6455 If you're preloading then I assume you're adding the healthbar at runtime and not in the scene editor? If so then are you instancing it? And it would be a var. `var h = preload("path_to_healthbar_scene").instance()` After that you need to add it as a child to the player and position it. You're better off just adding it in the scene editor though. Runtime is better for things you need to add dynamically. Then to connect it, you connect from the player to the healthbar, so: `connect("health_updated", h, "_on_health_updated")` in the player script.
0:43-0:50 I really hate it when video games do this when they don't display the maximum of the fill value. When the fill decreases, it appears that the WHOLE bar reduces rather than part of it changes (for example: █████ (represents 50% but the other 50% isn't shown, so the end of the bar isn't shown) instead of: █████░░░░░ or outlines). Usually when a bar is represented without showing the max, it is usually the length of something next to it, such as text on top or under it (assuming the bar is horizontal) or the width of the screen.
How does one go about making the health bar a series of containers instead? I mean, I don't want a health bar for my player. I want the health to be displayed as a series of heart sprites.
2:40 Few indie games ever display the damage section on the health bar. Cave story is one example. Edit: I might be wrong- it could be most indie games do that nowdays.
Some games like kirby super star ultra uses a rapid-flicker, alternating between current and previous HP every frame. This gives a transparent bar between current and previous HP.
@@ghb323 There are countless variations you can implement. I would disagree that few use it though. I see it quite often, but whether or not you use it is up to you. Personally I consider it to be bad design not to have it. Cave Story included. Without it, it's difficult to see how much damage has been dealt. The Kirby implementation you mentioned sounds really interesting, and serves another purpose of getting your attention, providing extra feedback to the player and keeping them aware of their health.
Game Endeavor the reason why they rapid-flicker is because of graphic limitations. Most have to do with overlapping graphics. This is not possible on the SNES on the same layer. This documented here: www.smwcentral.net/?p=section&a=details&id=21518 (I made this) on “double bar” mentions you can get around this by manually drawing all possible tiles (which takes up a lot of graphic space for each combination). The SNES is tile-based, normally its a grid of 8x8 cells. Placing the whole bar must be broken into individual tiles in order for it to work.
Game Endeavor also, some games display HP bars segmented, like God of war (2018), I don’t know if each segment represents a set amount of HP (1 block = 100HP, while the last segment can be less)
Game Endeavor it’s also a good idea to display how much healed. Done by having the second bar show the current HP healed, while the main bar is delayed.
Game Endeavor oh, so from the “background” to the “foreground”, you wanted: under, damagebar, and then healthbar. Otherwise the under covers the other bars.
Great tutorial as usual, I was able to get everything implemented, except for the _flash_damage function. I know the function is being called every time due to the print message, but my healthbar flashes only on a single occasion, which is when I first get into the danger zone and even then it's an extremely quick flash. Other than that one quick flash though, it acts like I don't have the flash function at all other than the print message any help would be greatly appreciated. code included: # script HealthBar extends Control signal pulse const FLASH_RATE := 0.05 const N_FLASHES := 4 export (Color) var healthyColor := Color.green export (Color) var cautionColor := Color.yellow export (Color) var dangerColor := Color.red export (Color) var pulseColor := Color.darkred export (Color) var flashColor := Color.orangered export (float , 0 , 1 , 0.05) var cautionZone := 0.5 export (float , 0 , 1 , 0.05) var dangerZone := 0.25 export (bool) var willPulse := false export (bool) var willPulseMusic := false onready var healthBarOver := $HealthBarOver onready var healthBarUnder := $HealthBarUnder onready var updateTween := $UpdateTween onready var pulseTween := $PulseTween onready var flashTween := $FlashTween func on_health_updated(health : float , amount) -> void: updateTween.interpolate_property(healthBarUnder , "value" , healthBarUnder.value , health , 0.4 , Tween.TRANS_SINE , Tween.EASE_IN_OUT , 0.4) updateTween.start() healthBarOver.value = int(health)
_assign_color(health) if amount < 0: _flash_damage() pass func _assign_color(health : float) -> void: if health == 0: pulseTween.set_active(false) elif health < healthBarOver.max_value * dangerZone: if willPulse: if !pulseTween.is_active(): pulseTween.interpolate_property(healthBarOver , "tint_progress" , pulseColor , dangerColor , 1.2 , Tween.TRANS_SINE , Tween.EASE_IN_OUT) if willPulseMusic: pulseTween.interpolate_callback(self , 0.0 , "emit_signal" , "pulse") pulseTween.start() else: healthBarOver.tint_progress = dangerColor else: pulseTween.set_active(false) if health < healthBarOver.max_value * cautionZone: healthBarOver.tint_progress = cautionColor else: healthBarOver.tint_progress = healthyColor pass func _flash_damage(): for i in range(N_FLASHES * 2): var color = healthBarOver.tint_progress if i % 2 == 1 else flashColor var time = FLASH_RATE * 1 + FLASH_RATE flashTween.interpolate_callback(healthBarOver , time , "set" , "tint_progress" , color) flashTween.start() print("flash") pass func on_max_health_updated(max_health) -> void: healthBarUnder.max_value = max_health healthBarOver.max_value = max_health pass
Something with WebGL exports. If it's about the game linked, then it might be a browser thing. Someone else I know was able to play it in a different browser.
@@ronaldpikksaar2202 Interesting. Usually Firefox is the better choice for this iirc. I don't remember, I'd try Chrome. I use Chrome and don't have an issue.
Ninja tutorial, good but waaaaaay too fast, did I miss the section where you create the hud interface with as you just threw that in there with no explanation, all within the first 1min 15 secs lol
I haven't done tutorials in nearly a year, and when I did they weren't beginner friendly step-by-step tutorials. They're "Here's how you would go about it, now go implement it yourself" tutorials. Learn concepts, not steps.
@@GameEndeavor the weird thing is you try to teach beginner ideas, but never actually deal with the basics. anyone who could follow this, probably doesn't need this.
It's not my job to provide you with assets, bud. I drew these, they're mine, go get you own, lol. And oh yeah? Well I just disliked your comment. Two can play that game. It's literally just three rectangles. Anyone with MS Paint can draw these.
"Am I so cruel that I enjoy teasing you with the idea of using a tween and then pulling the rug out from under you? Absolutely but that's not relevant here." that had me dying
Lol 😂 I was gonna comment this but already taken, so I'll just take the first reply 👍
Danger Zone!! :D Underrated channel.
Haha! This comment means a lot to me actually. Was worried I was too cringy with that joke. Thanks. ;D
Very Nice bro !! Im waiting for the floor and explosion. Love your tutos, keep doing this !! Greetings
Thanks! That should be very soon, so you shouldn't have to wait too long. :)
Thank you so much for the clear and succinct tutorial. I love the high speed so it's easy to ignore the parts I know and pause on the parts I need to pay attention. Liked and Subscribed!
Thanks for watching, glad it was useful. :)
To anyone confused: the health related events that seemingly arrive "out of nowhere" were created in the previous video in this series.
Thank you for all the videos you upload on your channel! I'm so glad I could find this channel, considering it's more of less underrated. I also love how you manage to keep videos always under 10-15 minutes! Great job, keep up the good work! :D
Great tutorial! "and even plays a soft soothing sound quietly in the background" haha keep up the great work!
Thank you!
Fantastic tutorial, but I had to lower the speed to 0.75 so I could follow it.
Oh man that tutorial is great! Thank you so much for that!! :)
Oh, boy! This is a quality tutorial.
How did you link the health bar to the player?
4:30 Haha I was doing the same when you first said "danger zone" xD Gotta blast that song again now, thank you...
Also, there is also a repeated-icon based health meter, much like Legend of Zelda. This is done by using an array and a loop to draw each icon. For fractional values, (fraction of an icon), you can do repeated subtraction (until the remaining units is 0 or negative) or division with remainder to determine the full and fractional icons.
For example, each heart has 4 units, and you have 2 full hearts + 1 quarter. Therefore you have 9HP:
9 - 4 = 5 (first heart is 4/4), use the difference for the next heart...
5 - 4 = 1 (second heart is also 4/4), take the difference for the next heart...
1 - 4 = -3 (went in the negatives! So take that remaining value to be this third heart (1/4)).
So if you subtract and doesn't result negative, then it is a full heart. If you subtract something bigger, then the minuend is the value of the last heart that isn't empty.
This tut is so on point and easy to understand. You earned a subscription and way more subscribers. ;) Keep this great work up. *cheers*
I created an enemy with attack, how can i implemnt this health bar so my character takes damage when he enters the area2d attack of an enemy?
Also, if you're planning to add numbers display for HP (including displaying damage numbers), make sure you have them as int and not floats. Even if you make the display use a round-to-whole number function, it may be possible the player notice that the damage value is 1-unit off (inconsistent damage). And to display it as a bar, you have to multiply before you divide so that you don't end up with a bar only displaying 0% (if HP is 0 or less than max) or 100% (max), like [HP*100/MaxHP] instead of [HP/MaxHP*100] because each mathematical operation (specifically division in this case) does the rounding towards zero in the int world.
You may lose some pixel precision, however it is very possible to create rounded-division by checking the remainder being greater than half the divisor, then increase the quotient by 1, otherwise leave the quotient be.
Gret tutorial, but I have one question, I'm trying to connect the health bar to the player while it's in a Canvas Layer UI. Do you know how to do this?
Game Endeavor, how do i set up a player getting dealt damage/player taking damage?
Great video but i have a question this might sound stupid but i am new to godot how to i apply this to enemies and how do i make it when the player collides with something he looses health i already did the coding from the tutorial but i dont know how to apply it
Hi the tutorial is great, but how can I link the health bar to the player so when it takes damage the bar could change?
You need to call the _on_health_updated() method on the healthbar. You can do so via a signal if your character emits one when their health is updated.
How exactly did you implement the shake node into the healthbar? Did you use a signal of some kind?
very pog 10/10 thank u
well done, that's a really good tutorial, but I have one question, I didn't understand what "amount" is for in the _on_Health_update, and which value I should put in there. Again, thank you very much for making these great tutorials!
What does mean (0) (1) and (0.05) in:
export (float, 0, 1, 0.05) var caution_zone = 0.5
??
nice bruh, im from Indonesian and im a indie game developer. In my country lot of a Indie Game Developer, and i try it in godot. thx bro
What would be the Godot 4 equivalent to the tween set up for this health bar?
This is perfect to taking damage, but for healing ?
Can you make a new video with this feature please ?
Great idea. Yeah, I'll look into it.
My Health is not getting updated when taken damage. Did i something wrong?
im to stupid to understand where i can call the function _set_health() and _set_max_health()
can anyone help me?
Wonderful.. thanks
Hey there! Regarding the health bar keeping the bright color and not returning due to the tween "getting stuck"... I've found that Tweens seem to "forget" their interpolate_property instructions
I keep running into an error "Invalid set index 'Value' (on base: 'Nil') with value of type 'float'" here's the section that if giving the problem
onready var health_bar = $HealthBar
func reciving_stats(HP):
health_bar.value = HP
Any solutions or Ideas?
"on base: 'Nil'" means that the health_bar variable is null. It probably isn't being set properly. Check the path, spelling, etc.
Can you please put your projects on github so we could study the code?
I have figured out how to make the HealthBar but the Bar is not filled right away. What could be the problem?
Awesome tutorial man! This really helped me with some logic on a UI element I'm adding to my game. Question though, how would you make the health bar that's hovering over the player not affected by things like a canvas modulate? Because I had a day and night system in my game and i don't want my UI's that move with my player to be affected by the coloration of the day. When I try adding these UI's to a different canvas layer node they no longer follow the player and now follow the camera so I'm a bit stuck now. I feel like adding the UI to a new CanvasLayer is the way to go, but I'm not sure how to glue that canvas layer on top of the player properly I guess
That's a good question that I never considered actually. My first though would be to much like you said, add it to a layer above. You might be able to anchor it to the character via RemoteTransform2D. The healthbar might need a Node2D base for that. I don't know that a RemoteTransform2d can position a Control node, let alone properly.
@@GameEndeavor Good idea! I've never used the RemoteTransform2D node before but I'll try experimenting with that. But yeah you're right it doesn't work with Control nodes so I'll need to change the base to a Node2D
I really like C#. Could you tell me the performance difference between GDScript vs C#?
Not specifically, but C# is considerably better performance wise. GDScript is better integrated into the engine, but C# is better for performance.
@@GameEndeavor Thanks for the fast reply😃 Then I stick to C#.
I'm having an issue where the healthbar just stays at one health an never changes ;-;
im using this code
---extends Control
onready var health_bar = $Healthbar
func _on_health_updated(health, amount):
health_bar.value = health
func _on_max_health_updated(max_health):
health_bar.max_value = max_health---
You have to tell the player to update the health on the bar, you can use (player script) get_tree().call_group("health bar group name","health updating function")
i was able to connect the player's healthbar, but i had to remove the "amount" from _on_health_update and because of that, now the _flash_damage() function is unused. i'm still not being able to connect it with the GUI healthbar.
nice tutorials btw i love them :) keep it up
I have the same problem you have. Did you come up with a solution?
How'd you connect the player's health bar?
I'm new, what should I write in the player script to connet it with a signal to the healthbar?
Nice, added it to 3.1 Godot Tutorials.
Hello :) first of all thanks for the tutorial. I have a question in the _on_health_updated(health) method , on the line " health_over.value = health" I get this error Invalid set index 'value' (on base : Color') with value of type 'int' . Do you have any idea why my TextureProgress value doesn't get updated?
Update: found a solution , it seems that if i use directly $HealthOver.value = health it works :P
@@alexandracherciu Howdy. :) Thank you for watching it. Looks like you might've misassigned your health_over as a color. The defining of it should look something like this `onready var health_over = $HealthOver`. Your solution is just as valid though. I tend to cache all of my used nodes into variables. Your fix just skips that step. :)
What would be the best way to connect the "pulse" signal to the Player? Like if the HealthBar is in the UI, where should connect() be called? For example, in a node that is a parent of both the Player and UI, or in the Player's script by passing the HealthBar to the Player somehow? Thank you!
PS. I love how you weave in little jokes during busy work moments like just creating a node so I can laugh without missing anything.
Good question. There are various ways you could do this. A lot of times when I create a level, I won't directly instance the player in the scene from the inspector. Instead I will create a spawn point and in the level code I'll have it spawn the character at that location. During that process I would connect the signals there. I prefer this method since it allows for such flexabilities. For example this would also come in handy if you allowed the player to select from a roster of characters before entering the level.
Alternatively if you know that the level is going to be the current scene, then you could cache it in the level script, then in the player's _ready() method you could call `get_tree.current_scene.health_bar.connect()`. However (without extra checks) doing that would lock you into that setup and require that the player always be instanced with the level as the current scene.
Glad you like the jokes. :) I love hearing that people are enjoying them.
@@GameEndeavor ahh, I like that first method a lot, I think that will be my game plan! Thank you for the quick response and all the awesome tutorials!
Can anyone help me fix the amount isn't declared in the current scope?
how to connect to the last lesson with health and dammage
its not working how to connect this health bar to a player?!wtf
htf you resized when were instancing the scene?!
oh I see... scale...
This isn't working, where is the complete step when connecting HP with player script?
It's just a signal connect. You can either do it through the inspector, or through the code ie connect("health_updated", $HealthBar, "_on_health_updated")
@@GameEndeavor Sorry but don't get it. Is there a reference to some other video? How to calculate percentages (where is the clamp function or some other way of measuring values between max and min!?)
@@petarkosovic6455 There is no method, you don't need to calculate percentages. ProgressBars have a max_value and a value property. They do the work for you. But calculating percentage is just `value / float(max_value)` (* 100 to make it a true percentage, but that's rarely useful)
@@petarkosovic6455 If you're preloading then I assume you're adding the healthbar at runtime and not in the scene editor? If so then are you instancing it? And it would be a var. `var h = preload("path_to_healthbar_scene").instance()` After that you need to add it as a child to the player and position it. You're better off just adding it in the scene editor though. Runtime is better for things you need to add dynamically.
Then to connect it, you connect from the player to the healthbar, so: `connect("health_updated", h, "_on_health_updated")` in the player script.
0:43-0:50 I really hate it when video games do this when they don't display the maximum of the fill value. When the fill decreases, it appears that the WHOLE bar reduces rather than part of it changes (for example:
█████ (represents 50% but the other 50% isn't shown, so the end of the bar isn't shown)
instead of:
█████░░░░░ or outlines).
Usually when a bar is represented without showing the max, it is usually the length of something next to it, such as text on top or under it (assuming the bar is horizontal) or the width of the screen.
I do not know but it does not work. Did you connect your signals or smthg?
Yeah, connect your `health_updated` signal to `_on_health_updated()`.
@@GameEndeavor Hi. I'm sorry but How do you code that?
How does one go about making the health bar a series of containers instead? I mean, I don't want a health bar for my player. I want the health to be displayed as a series of heart sprites.
2:40 Few indie games ever display the damage section on the health bar. Cave story is one example.
Edit: I might be wrong- it could be most indie games do that nowdays.
Some games like kirby super star ultra uses a rapid-flicker, alternating between current and previous HP every frame. This gives a transparent bar between current and previous HP.
@@ghb323 There are countless variations you can implement. I would disagree that few use it though. I see it quite often, but whether or not you use it is up to you. Personally I consider it to be bad design not to have it. Cave Story included. Without it, it's difficult to see how much damage has been dealt. The Kirby implementation you mentioned sounds really interesting, and serves another purpose of getting your attention, providing extra feedback to the player and keeping them aware of their health.
Game Endeavor the reason why they rapid-flicker is because of graphic limitations. Most have to do with overlapping graphics. This is not possible on the SNES on the same layer. This documented here: www.smwcentral.net/?p=section&a=details&id=21518 (I made this) on “double bar” mentions you can get around this by manually drawing all possible tiles (which takes up a lot of graphic space for each combination).
The SNES is tile-based, normally its a grid of 8x8 cells. Placing the whole bar must be broken into individual tiles in order for it to work.
Game Endeavor also, some games display HP bars segmented, like God of war (2018), I don’t know if each segment represents a set amount of HP (1 block = 100HP, while the last segment can be less)
Game Endeavor it’s also a good idea to display how much healed. Done by having the second bar show the current HP healed, while the main bar is delayed.
watched like 3 videos to learn how to this but something just didn't feel right. Untill i found this😀
2:59 “remove the under texture” what happens if you don’t?
You won't be able to see the health bar under it. You want the under texture to be on the healthbar that's behind the top one.
Game Endeavor oh, so from the “background” to the “foreground”, you wanted: under, damagebar, and then healthbar. Otherwise the under covers the other bars.
@@ghb323 Yup.
If doesn't work, remove "amount" from your = func _on_health_updated(health, amount):
where is download link sprite health bar ????
Great tutorial as usual,
I was able to get everything implemented, except for the _flash_damage function.
I know the function is being called every time due to the print message, but my healthbar flashes only on a single occasion, which is when I first get into the danger zone and even then it's an extremely quick flash. Other than that one quick flash though, it acts like I don't have the flash function at all other than the print message
any help would be greatly appreciated.
code included:
# script HealthBar
extends Control
signal pulse
const FLASH_RATE := 0.05
const N_FLASHES := 4
export (Color) var healthyColor := Color.green
export (Color) var cautionColor := Color.yellow
export (Color) var dangerColor := Color.red
export (Color) var pulseColor := Color.darkred
export (Color) var flashColor := Color.orangered
export (float , 0 , 1 , 0.05) var cautionZone := 0.5
export (float , 0 , 1 , 0.05) var dangerZone := 0.25
export (bool) var willPulse := false
export (bool) var willPulseMusic := false
onready var healthBarOver := $HealthBarOver
onready var healthBarUnder := $HealthBarUnder
onready var updateTween := $UpdateTween
onready var pulseTween := $PulseTween
onready var flashTween := $FlashTween
func on_health_updated(health : float , amount) -> void:
updateTween.interpolate_property(healthBarUnder , "value" , healthBarUnder.value , health , 0.4 , Tween.TRANS_SINE , Tween.EASE_IN_OUT , 0.4)
updateTween.start()
healthBarOver.value = int(health)
_assign_color(health)
if amount < 0:
_flash_damage()
pass
func _assign_color(health : float) -> void:
if health == 0:
pulseTween.set_active(false)
elif health < healthBarOver.max_value * dangerZone:
if willPulse:
if !pulseTween.is_active():
pulseTween.interpolate_property(healthBarOver , "tint_progress" , pulseColor , dangerColor , 1.2 , Tween.TRANS_SINE , Tween.EASE_IN_OUT)
if willPulseMusic:
pulseTween.interpolate_callback(self , 0.0 , "emit_signal" , "pulse")
pulseTween.start()
else:
healthBarOver.tint_progress = dangerColor
else:
pulseTween.set_active(false)
if health < healthBarOver.max_value * cautionZone:
healthBarOver.tint_progress = cautionColor
else:
healthBarOver.tint_progress = healthyColor
pass
func _flash_damage():
for i in range(N_FLASHES * 2):
var color = healthBarOver.tint_progress if i % 2 == 1 else flashColor
var time = FLASH_RATE * 1 + FLASH_RATE
flashTween.interpolate_callback(healthBarOver , time , "set" , "tint_progress" , color)
flashTween.start()
print("flash")
pass
func on_max_health_updated(max_health) -> void:
healthBarUnder.max_value = max_health
healthBarOver.max_value = max_health
pass
where is the HUD ?
Like always... great tutorial!
Thank you!
i want beta?
ily
"GLctx is undefined" - what does it mean?
Something with WebGL exports. If it's about the game linked, then it might be a browser thing. Someone else I know was able to play it in a different browser.
@@GameEndeavor Thanks for the reply. I have Firefox, what did they have?
@@ronaldpikksaar2202 Interesting. Usually Firefox is the better choice for this iirc. I don't remember, I'd try Chrome. I use Chrome and don't have an issue.
@@GameEndeavor I can't use Chrome. I now used Opera and it worked, so that's settled. :D Thanks again.
lol didnt even show how to connect it to the actual health..
Great Channel Great Work but what you do amount
I wish you would have shared the sprite images for the health bars.
opengameart.org/content/health-bar-base-godot
Ninja tutorial, good but waaaaaay too fast, did I miss the section where you create the hud interface with as you just threw that in there with no explanation, all within the first 1min 15 secs lol
Play at 0.75
9:26 how
1:58
too fast please use step by step method thanks
I haven't done tutorials in nearly a year, and when I did they weren't beginner friendly step-by-step tutorials. They're "Here's how you would go about it, now go implement it yourself" tutorials. Learn concepts, not steps.
@@GameEndeavor the weird thing is you try to teach beginner ideas, but never actually deal with the basics. anyone who could follow this, probably doesn't need this.
@@Zethyguitarist And yet I was well known for my tutorials at the time.
why you talk so fast man!
Because the faster I talk the less work I have to do. My tutorials are notoriously fast and to the point. Just how it is.
@@GameEndeavor i learned a lot from your tutorials but every video i watch i have to reduce the speed to .5 lol
Terrible tutorial
love how you don't give us the sprites lol. disliked
It's not my job to provide you with assets, bud. I drew these, they're mine, go get you own, lol. And oh yeah? Well I just disliked your comment. Two can play that game.
It's literally just three rectangles. Anyone with MS Paint can draw these.
opengameart.org/content/health-bar-base-godot
I created some they might be rubbish, but try them out.
@@awiggan1 ooo.. No need for that man