Easy Heart Health System in Unity

Поделиться
HTML-код
  • Опубликовано: 28 сен 2024

Комментарии • 49

  • @mandamoon9149
    @mandamoon9149 2 года назад +3

    Bmo videos have single handedly dropped my cholesterol and now my heart is healthy ❤️

  • @kristinewestman5502
    @kristinewestman5502 6 месяцев назад

    So easy to understand. I spent all day trying to get my health system to work. Watched many different videos. Tried my own ideas. Then I found this! Thank you so much. Now, I can get on with the rest of my game.

  • @emsaik8202
    @emsaik8202 2 года назад +5

    I'm finding your videos really helpful, they inspired me to start learning more about unity and start making my first game so thanks for the work!!

    • @BMoDev
      @BMoDev  2 года назад

      wooo lets gooo, make a masterpiece I'm always looking for something fun

  • @suicune2001
    @suicune2001 2 года назад +3

    Thanks! I need to get more familiar with those layout groups. They seem very useful for getting buttons and such in a nice neat order.

  • @eileeng2492
    @eileeng2492 2 года назад +1

    Thank you for the clear tutorial and explanation
    Much appreciated

  • @opxv
    @opxv 2 года назад +10

    This is like the reincarnation of Brackeys... easy to understand, follow and build upon. Thank you!

  • @DivyanshuLohani
    @DivyanshuLohani 2 года назад

    Bro very much thank you I literally was stuck on this problem for 3 days

  • @wortwortwort117
    @wortwortwort117 2 месяца назад

    So what would we do if we wanted each heart to only be one health

  • @adimortal3195
    @adimortal3195 Год назад +1

    can you explain a liittle bit of this OnPlayerDamaged event ?
    because i only using
    health = health - 1
    every time it taking damage

  • @antonmayer7891
    @antonmayer7891 2 года назад +1

    Hi this video is really helpfull but I managed to run into an issue anyways. When I start my game all hearts are there but empty. As soon as my Player takes damage all hearts fill excapt of that what I lost. So now everything is working properly again. Can u help me...?

  • @noanfelipe4753
    @noanfelipe4753 7 месяцев назад

    Great video! helped a lot

  • @puffosgamingoldchannel5992
    @puffosgamingoldchannel5992 Год назад +1

    Hey, I have ran into a problem with the script for the health bar. I have done everything you stated to do (even changing some numbers to make the UI work in my favour) and for some reason the hearts just don't want to change sprites.
    I am trying to do a quarter health system (minimum of 0, maximum of 4) and whenever I tried to change the health of the player the sprites for the hearts would never change, they would always be full.
    I am honestly scratching my head on this one and I can't find a solution to this problem, really want to learn how to do this health system as it would help immensely in a project I'm working on and would help me in the future on other projects.

  • @weckar
    @weckar 2 месяца назад

    Why not just make the hearts a mask for a variable length health bar underneath? Then you can have any fraction at a whim and even animate it draining down without additional sprite graphics.

  • @NothingburgerOnG
    @NothingburgerOnG Год назад +1

    My hearts dont update when im damaged? everything else works and i get the console meesage that i have died but the hearts dont change?

    • @shockingchris9809
      @shockingchris9809 10 месяцев назад +1

      I am getting a similar issue. What seems to happen is that the named "HealthHeartBars" Or whatever better name people have is active and enabled and it appears it won't reinvoke or enter the method since it does not disable or go inactive. My thought is the set it inactive and set it active again, but I feel like there is some circular logic here to reference the UI HeartBars within the "PlayerHealth" script (or whatever you call yours).

    • @NothingburgerOnG
      @NothingburgerOnG 10 месяцев назад

      @@shockingchris9809 haha its been a while since i used this tutorial. I think i fixed it in the end but dont know how. My games was great tho

  • @danielduduleanu7517
    @danielduduleanu7517 2 года назад

    I had default settings, yet somehow my hearts are placed from top to bottom instead of left to right. Do you have any ideea why?

  • @VFORVICTORY1000
    @VFORVICTORY1000 2 года назад +2

    HElpful thx

  • @raulmelgar8903
    @raulmelgar8903 Год назад

    THANK YOU!!!!!!!!

  • @brianpizarro2744
    @brianpizarro2744 2 года назад

    Thank you

  • @taraskhan475
    @taraskhan475 4 месяца назад

    I like this, but please don't spawn in stuff without notice, like code and such

  • @Anerisian
    @Anerisian 2 года назад +1

    The “crazy math” part is not necessary. You see, hearts are either full or empty, except for one “broken” heart in between. It should be easy to find where the broken heart is at i.
    the logic is simply:
    int fullHearts = healthCurrent / 4;
    and then in the for loop…
    if (i < fullHearts) set the full heart image here.
    if (i == fullHearts) set the broken heart here.

  • @郑竣谦-d5n
    @郑竣谦-d5n 2 года назад

    pm me script pleash

  • @eaoa1234
    @eaoa1234 6 месяцев назад

    this is very disappointing I really wanted to make it for 3D but this is not for 3D this is for 2D so thanks for absolutely nothing

    • @TheGrassKing
      @TheGrassKing 6 месяцев назад

      thats not how that works you can still do that for 3d

  • @xavvey
    @xavvey 2 года назад +9

    I watch a lot of gamedev channels on youtube and I can say that there aren't a lot of (maybe 1 or 2. There was Brackey but he quit...) those that give these clear, understandable, easy to follow and great small videos! I have been searching a while for this before you popped up on my feed!

    • @BMoDev
      @BMoDev  2 года назад +2

      Thats a big compliment! thanks

  • @vvcephie113
    @vvcephie113 2 года назад +5

    Can you please do a tutorial on how to do 2 players with one keyboard. (WASD)(Arrow Keys) This would be very helpful to me and probably a lot of other people because there is not another 2d 2 player video with gravity. Thanks. BTW love the vids, subbed

    • @madpenguin58
      @madpenguin58 2 года назад

      All you need to do is create another set of axi in your inut system, or just have map the buttons and have a way to tell the script which player is which

  • @MaizaMriza
    @MaizaMriza 2 года назад +8

    I ran into scaling issues after following the guide. Everything works correctly except every time a new prefab is instantiated the scaling was set to 45,45,45 and the heart would basically be huge af. To fix that I had to set the scaling in the code. under CreateEmptyHeart method I just added one line: newHeart.transform.localSacle = new Vector3(1,1,0) this should fix the problem if you run it to it as well. It could be because I used a random heart image from google. !

    • @mitygamedev5882
      @mitygamedev5882 Год назад +1

      it could be because you touched the settings in Grid Layout (or you should and did not) the default was 100x100 i changed to 64x64 for my project and works perfect.

  • @Stompin40
    @Stompin40 2 года назад +3

    Sick video! Very helpful!

  • @PETERk-vm3gm
    @PETERk-vm3gm 2 года назад +3

    fucking hell i just spoke to a mate about how to add health system and boom 10 minutes later this video recommended on home page
    but great video and thanks

    • @BMoDev
      @BMoDev  2 года назад +2

      haha typical - appreciate it!

  • @godzillakingkongvenom
    @godzillakingkongvenom 2 года назад +2

    Holllaaa

  • @trstation3172
    @trstation3172 2 года назад +2

    ı love you

  • @Tonesko5
    @Tonesko5 2 года назад +1

    Anybody know my it won't let me assign my player to the player health

  • @felixalcatraz7489
    @felixalcatraz7489 2 дня назад

    doesn't work :l

  • @dashadventure9952
    @dashadventure9952 2 года назад +1

    Please a new and improved 2d top down movement tutorial

  • @yojan69
    @yojan69 Год назад

    help, why does it rests 2 hp (a whole heart) if i did set "takedamage 1"?, my game has 20hp, 10 hearts, i can't find why :(

  • @Electorch
    @Electorch Год назад

    public void Hp()
    {
    if (three.sprite != emptyHeart)
    {
    if (three.sprite == fullHeart)
    {
    three.sprite = halfHeart;
    }else if (three.sprite == halfHeart)
    {
    three.sprite = emptyHeart;
    }
    }
    else if (two.sprite != emptyHeart)
    {
    if (two.sprite == fullHeart)
    {
    two.sprite = halfHeart;
    }else if (two.sprite == halfHeart)
    {
    two.sprite = emptyHeart;
    }
    }else if (one.sprite != emptyHeart)
    {
    if (one.sprite == fullHeart)
    {
    one.sprite = halfHeart;
    }else if (one.sprite == halfHeart)
    {
    one.sprite = emptyHeart;
    }
    }
    }

  • @TahneeEvans
    @TahneeEvans Год назад

    How do you get this to work if you are using public health and maxHealth floats within the HealthHeartManager script?

    • @blaze9433
      @blaze9433 Год назад +1

      You just gotta do it like he first showed. Instead of referencing the playerhealth script, use "public float health, maxHealth;"
      Then, just substitute those parameters everywhere in the script where he referenced playerhealth.

  • @yamaNGap
    @yamaNGap 2 года назад

    how do i make a script if i want each enemy type to have different damage?

    • @lucky6961
      @lucky6961 Год назад

      just the damageoncollision script from 1 to the value you want, example if you want the void to instant-kill you can instead just make it set to 0 meaning death

    • @tirilmariepedersen6956
      @tirilmariepedersen6956 11 месяцев назад

      I suggest looking into Scriptable Objects, this was a game changer for me C:
      SO stores data for you, so you can have everything from:
      Enemy name
      Health
      Speed
      Damage
      Prefab of the enemy containing ex: sprite, animator etc
      And so on..
      Then you can instantiate the prefab in the data container and voila! A enemy with the current data values emerges
      And then u can keep making more by making more SO with different enemies.
      Oh! You can make SO with anything; weapons, objects, player appearance.. :3
      It's AMAZING! :D
      Cheers