How to Add Health Bars to Your Games in GDevelop

Поділитися
Вставка
  • Опубліковано 1 лют 2025

КОМЕНТАРІ • 63

  • @isfunart
    @isfunart Рік тому +3

    wow beautiful tutorial, short, quick and simple. Love it keep it up making more!

    • @Winstreak1
      @Winstreak1  Рік тому +2

      Thanks IzFan!
      I will keep on making them if you keep on watching them. :)

    • @isfunart
      @isfunart Рік тому +1

      Notification on!

    • @Winstreak1
      @Winstreak1  Рік тому

  • @Kjx9Beats
    @Kjx9Beats 2 роки тому +1

    You are an amazing youtuber, no joke. Man love ur content, u helped me out a lot. You are really underrated

    • @Winstreak1
      @Winstreak1  2 роки тому

      Thank you so much!
      I notice you watch both my Construct and GDevelop content. Do you use both engines?

    • @Kjx9Beats
      @Kjx9Beats 2 роки тому

      @@Winstreak1 no actually I don’t but it’s still good to get basic knowledge for different engines

    • @Winstreak1
      @Winstreak1  2 роки тому

      @@Kjx9Beats Oh, well thanks for watching both then! :)

  • @Sunret
    @Sunret Рік тому +3

    I wasn't satisfied with basic reource bar, cause I had some issues with decreasing max health (the bar was stretching or it looked like it is not full but the digits on it said opposite thing). And you actually gave me an excellent idea. Thanks!

  • @DeavtheDev
    @DeavtheDev 4 місяці тому

    Amazing Video Bro! This worked perfectly!

    • @Winstreak1
      @Winstreak1  4 місяці тому

      Glad to hear it!
      What's the project you are working on?

  • @swapbloodcell
    @swapbloodcell 9 місяців тому

    thank you for showing the clamp feature. i had the rest figured out but that. much appreciated

    • @Winstreak1
      @Winstreak1  9 місяців тому +1

      Haha happy to help, even if it was just a tiny nugget!

  • @GarrisonStudios
    @GarrisonStudios 2 роки тому +1

    Thanks for making this tutorial. Looking forward to more. 😀

    • @Winstreak1
      @Winstreak1  2 роки тому

      Glad you enjoyed it!
      I’m currently doing a Super Mario World multi part tutorial.The first episode is out if you haven’t seen it yet.
      ua-cam.com/video/qGcbQXH7oOY/v-deo.html

  • @supjay3945
    @supjay3945 11 місяців тому +1

    Im just thankful that this tutorial wasnt like the ones I just watched. It had no narration and was sped up.

    • @Winstreak1
      @Winstreak1  11 місяців тому

      Thanks!
      No promises on not speeding things up, but I will always do my best to talk you through what's going on.

  • @TrEeBLaZe
    @TrEeBLaZe Рік тому +1

    I assume this can be done for a weapon power bar, correct? For instance if you're shooting a laser, set max ammo & current ammo too 100, then set the condition for example, when left mouse is click
    Action: subtract 1 from ammo variable
    Action: ammoBar width set to ammo algorithm.....does that sound right?

    • @Winstreak1
      @Winstreak1  Рік тому

      Yes, sounds like you are on the correct path. Feel free to try it out and if you bump into problems let me know them and I will help you out.

    • @TrEeBLaZe
      @TrEeBLaZe Рік тому

      @Winstreak1 gonna test it when I'm back at my pc in a few hours....currently I have the firing set to just the left mouse button to just be held down (not repeatable click) cause its a rapid fire laser.....so I still need to add a trigger once to execute the action or no?

    • @Winstreak1
      @Winstreak1  Рік тому

      @@TrEeBLaZe As long as your action where you are firing your bullet is also subtracting from your ammo - whether you make it once per click or hold and shoot is up to you

    • @TrEeBLaZe
      @TrEeBLaZe Рік тому

      @Winstreak1 ok understood thanks, ill let you know how it works out

    • @TrEeBLaZe
      @TrEeBLaZe Рік тому

      @Winstreak1 sorry,Unrelated question to my previous, something I was curious about if thats ok....i want to restrict movement to only about ¾ of the left side of my layout, (making a little top down space shooter to learn the software better) I figure I can add just an hidden collision box at the border I want to keep the player from passing, but I don't want it to be an abrupt stop, like they just flew into an invisible wall! Lol
      Is there a way to kinda "buffer" the collision? So they have like lets say a 20 pixel grace area, before there pushed back away from the collision box, by a force I assume I would have to add to the player?

  • @DamasoBruno
    @DamasoBruno Рік тому +1

    thank A LOT buddy

  • @pixsoulgames9869
    @pixsoulgames9869 Рік тому +1

    How to do you use this same method to Heal the player?

    • @Winstreak1
      @Winstreak1  Рік тому

      Create any Event Condition you want for when the player should be healed. (Right click the hero would make sense for my example - for a game something like on collision with a heart object).
      The actions will be the same Except instead of subtracting from the health variable we will add to it.
      Note: Nothing in the code stops health from going above max health. We clamp the healthbar but there is no code to stop health from going higher than max health. You can fix that with a 1 line event: Condition if Variable of RedHero Health > Variable of RedHero Max Health | Action Set Variable of RedHero Health = to RedHero Variable MaxHealth

  • @greyghost1379
    @greyghost1379 Рік тому +1

    How would you make this health global?

    • @Winstreak1
      @Winstreak1  Рік тому +1

      Make all the objects you are using Global, this will allow you to use them on multiple scenes. If you are changing scenes and need to remember the current values you have in your Health bar Object Variables you will have to store them in a Global variable, I don't believe there is a way to send your current instance of the object from 1 scene to another.

  • @timetorelaxfocus9642
    @timetorelaxfocus9642 2 роки тому

    Nice, thanks

    • @Winstreak1
      @Winstreak1  2 роки тому

      Thank you for taking the time to watch my video's'! 🥰

  • @Volt-Eye.
    @Volt-Eye. 9 місяців тому

    How to do if i want to reduce length from left to right ?

    • @Winstreak1
      @Winstreak1  9 місяців тому

      Open the properties of the HealthBar Object and click the Edit Points button on the bottom left.
      Inside Edit Points you will want to move the Origin point from the left side to the right side.
      (You will need to re-align your HealthBar inside of the HealthBarBox on your Scene once you do this)

  • @erino_0
    @erino_0 2 роки тому

    Thanks so much for this tutorial! Just wondering how you make it follow the player and make it that once the health bar reaches 0 the player dies?

    • @Winstreak1
      @Winstreak1  2 роки тому +2

      Happy to help :)
      Technically, you would not want to set your hero to die based off the HealthBar, but instead based off the Hero Variable 'Health'.
      In a new event:
      Condition: Hero - Value of Object Variable is 'Less than or equal to' 0.
      Then you would put the death actions on the right side. Usually something like set death animation - drop gold - drop items.
      Then a new event for on hero death animation is finished - delete hero.

    • @erino_0
      @erino_0 2 роки тому

      @@Winstreak1 Thank you so much :)

  • @senselessvoid7331
    @senselessvoid7331 Рік тому +1

    DUDE THAT'S AWESOME! Anyway any idea how do you also change the Text that has the HP remaining of my Hero each time it reduces?

    • @Winstreak1
      @Winstreak1  Рік тому +1

      Sure!
      Add a text object this will display your Health. Anytime you want to update this - you can do it whenever damage is give or every tick - You will add an action to Change the text of (the new text object): Set to Hero.Variable(Health) - or whatever you named your Health variable and player to!

    • @senselessvoid7331
      @senselessvoid7331 Рік тому

      @@Winstreak1 COOL! But what if my max HP is set to 1000? what should I put in the Action variables since my lifebar is smol but has 1000 hp on it?

    • @Winstreak1
      @Winstreak1  Рік тому +1

      @@senselessvoid7331 You should have a variable for both your Health and MaxHealth - this will take care of the percentage calculations. The only value you have hard coded is (in my case) 311, 0 , 311.
      The first and last value is the width of your health bar, in the first position you are using it to multiply by your percentage. 1 (being 100%) multiplied by 311 would give you a full bar of 311, 0.5 x 311 would give you a half bar of 155.5. The second 311 is a clamp, this just stops the bar from traveling past 311 pixels which is a full bar.
      Last, the 0 is your clamp on the other end (dead character). This will protect your bar from going too far to the left if your character has negative health.
      If you have 1000 health you should only need to change your Health and MaxHealth Variables to match.
      If you change the size of your health bar you will need to change the 311 values.

    • @senselessvoid7331
      @senselessvoid7331 Рік тому +1

      @@Winstreak1 BRO THAT IS VERY HELPFUL! YOU EARN MY SUB *claps* THANK YOUU!!!

    • @Winstreak1
      @Winstreak1  Рік тому

      @@senselessvoid7331 Happy to help!
      Here's a link to my Discord, if you ever bump into problems I'll do my best to help you out. Discord makes it possible to share screen shots which makes debugging a lot easier :)
      discord.gg/B74N5qrpvU

  • @Kikioko78
    @Kikioko78 Місяць тому

    Why does the health bar instantly go to zero?

    • @Winstreak1
      @Winstreak1  29 днів тому

      The health bar has default values inside the properties make sure those are all set correctly

    • @Kikioko78
      @Kikioko78 29 днів тому

      @Winstreak1 all fixed thanks!

  • @john-r8b6u
    @john-r8b6u 3 місяці тому +1

    Thanks, how about new tutorials?

  • @_anidex_3372
    @_anidex_3372 2 роки тому

    It works thank you very much, but how do I do that when the bar ends the character is deleted?

    • @Winstreak1
      @Winstreak1  2 роки тому +1

      You should do it off the health variable if it is less than or equal to 0.
      I usually set a death animation at this point. If it’s an enemy you can add drops at this point and stop letting the enemy interact with the player. Once the death animation finishes delete the object.

  • @cevatfatihvazgecen6516
    @cevatfatihvazgecen6516 11 місяців тому

    I can't find value of an object section

    • @Winstreak1
      @Winstreak1  11 місяців тому

      You need to add the object variable to the object and make sure you are looking at Object variables when you are in your event sheet.
      Here are both the time stamped parts of the video:
      ua-cam.com/video/LhbqxPxZJ5I/v-deo.html
      ua-cam.com/video/LhbqxPxZJ5I/v-deo.html

  • @PattyPower-cq5rq
    @PattyPower-cq5rq Рік тому +1

    I thought this was about health bars HMMMMM. The ones we eat!!!!!

  • @palcube2467
    @palcube2467 11 місяців тому

    For me theres no object variables :/

    • @Winstreak1
      @Winstreak1  11 місяців тому +1

      You need to create the Object variables... Go back to 01:35

    • @palcube2467
      @palcube2467 11 місяців тому

      thx@@Winstreak1

  • @evawropa836
    @evawropa836 Рік тому

    Thanks

    • @Winstreak1
      @Winstreak1  Рік тому

      You're very welcome Evawropa! 😀

  • @satisho1096
    @satisho1096 2 роки тому

    Hi