How to Make A Simple HEALTH SYSTEM in Unity

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ธ.ค. 2024

ความคิดเห็น • 72

  • @TegridyMadeGames
    @TegridyMadeGames 3 ปีที่แล้ว +39

    Your videos are so fast but so descriptive. You don't just use "code talk" you explain it in lamens terms. All the meanwhile, making the tutorials about 2-3x shorter than your average Brackeyes tutorial.
    Keep it up, amazing videos! They help me a ton!

    • @BMoDev
      @BMoDev  3 ปีที่แล้ว +6

      Really cool to hear this, thanks!

    • @TegridyMadeGames
      @TegridyMadeGames 3 ปีที่แล้ว +1

      @@BMoDev i made a free game coming to steam soon using your 5 min pong tutorial too xD
      No, thank you!

    • @Mccev_Roric
      @Mccev_Roric 6 หลายเดือนก่อน

      @@BMoDev
      I don't know why, but the enemies don't hurt my player. I used debugs to find that the game knows the objects are colliding, but the enemies still don't hurt the player.
      Here are the scripts:
      1: "EnemyDamage"
      public class EnemyDamage : MonoBehaviour
      {
      private void OnTriggerEnter2D(Collider2D collision)
      {
      if(collision.tag == "Player")
      {
      var healthComponent = collision.GetComponent();
      if(healthComponent != null)
      {
      healthComponent.TakeDamage(2);
      }
      }
      }
      }
      2: "PlayerHealth"
      ​public class PlayerHealth : MonoBehaviour
      {
      public float currentHealth;
      public float maxHealth;
      public void TakeDamage(int amount)
      {
      currentHealth -= amount;
      if(currentHealth

  • @deadbroadcastpc
    @deadbroadcastpc 3 ปีที่แล้ว +18

    I like your explanation man, very entertaining

  • @thediodoin1000
    @thediodoin1000 2 ปีที่แล้ว +4

    Thank you so much! this was the only tutorial video for health system that would work thank you for making this video it helped me so much and saved alot of tears

  • @lightningcode1136
    @lightningcode1136 3 ปีที่แล้ว +7

    Yes! I could not find this in a Brackeys tutorial

  • @IceCream-sb7lc
    @IceCream-sb7lc 3 ปีที่แล้ว +8

    That intro, I now want some pineapple.. and health care. More importantly pineapple though lol. Solid tutorial BMo!

    • @BMoDev
      @BMoDev  3 ปีที่แล้ว

      🍍 rum & pineapple is the truth #trust

  • @amandacollins7392
    @amandacollins7392 3 ปีที่แล้ว +22

    3 pineapples a day keeps the doctor away ;) I understand health now!

    • @BMoDev
      @BMoDev  3 ปีที่แล้ว +3

      Thats right, stick with me I'll show you the truth

  • @LordBinzVR
    @LordBinzVR 3 ปีที่แล้ว +3

    Simple and easy. Excellent tutorial!

  • @xioned
    @xioned 3 ปีที่แล้ว +3

    That was so quick and awesone ACTUALLY ! I was looking for simple health system for so long and this showedup. :'''''') Thank you .You are a life saver.Good luck and bring us thanos just kidding.Bring us more videos like this

    • @BMoDev
      @BMoDev  3 ปีที่แล้ว

      Awesome, glad it helped out!

  • @eileeng2492
    @eileeng2492 3 ปีที่แล้ว +3

    Great!
    Examples so good!

    • @BMoDev
      @BMoDev  3 ปีที่แล้ว

      Thanks! 😃

  • @akizuki2971
    @akizuki2971 2 ปีที่แล้ว +2

    just came here from watching a video on the same subject by a 250k sub channel..... yours was better by a large margin. You actually explained what you're doing and i appreciate that. Thanks!

    • @BMoDev
      @BMoDev  2 ปีที่แล้ว

      Wow means alot. Thanks!

  • @lordkakabel76
    @lordkakabel76 3 ปีที่แล้ว +9

    I died... laughing! 😂

  • @KagamiFr
    @KagamiFr 3 หลายเดือนก่อน

    BRO I LOVE YOU SO MUCH

  • @andrewislastyear1118
    @andrewislastyear1118 3 ปีที่แล้ว

    Best prequel

  • @macaaris1018
    @macaaris1018 3 ปีที่แล้ว +2

    Great video 👍

    • @BMoDev
      @BMoDev  3 ปีที่แล้ว

      Thanks 🙏

  • @ASTARH
    @ASTARH ปีที่แล้ว +1

    hey i know im 2 years late but what is a health component

  • @wstevegaming593
    @wstevegaming593 3 ปีที่แล้ว +3

    Why do the arrows kill him if he's wearing full plate

  • @revmatch6r
    @revmatch6r 3 ปีที่แล้ว +2

    Better hope I'm not around when you only have one pineapple left ⚰

    • @BMoDev
      @BMoDev  3 ปีที่แล้ว

      😤😤

  • @shidou2380
    @shidou2380 ปีที่แล้ว +1

    im so confused, it has part or can follow from one video tutorial?

  • @uncyan
    @uncyan 3 ปีที่แล้ว +3

    your video is very Easy to understand
    so I wish there were Korean subtitles. cuz im korean

    • @BMoDev
      @BMoDev  3 ปีที่แล้ว +1

      Me too, if i ever make real money off the channel ill invest in subtitle translators

  • @hologrammaster2468
    @hologrammaster2468 2 ปีที่แล้ว

    THANK YOU

  • @THEWHITEGLOW07
    @THEWHITEGLOW07 8 หลายเดือนก่อน

    people: use this to make health bars...
    Me: Uses this to make a spam button...

  • @dkordy
    @dkordy 3 ปีที่แล้ว

    Great,but all of you with knowlege saying just like that,its simple like that or somthing...That word"JUST" It hurts,for complete beginers like me,nothing is not "JUST" NObody is born with knowlege... but compare to others you r sooo cool and i thank you for this tutorial...thanks

    • @BMoDev
      @BMoDev  3 ปีที่แล้ว +1

      Its all attitude, programming is 90% frustration, 10% elation. Approaching problems as simple hurdles will do much for your long term interest in programming.

  • @oedhelsetren
    @oedhelsetren 2 ปีที่แล้ว +1

    Something I've tried is not creating add and subtract methods. All methods are additive, the values can be negative.

  • @macaaris1018
    @macaaris1018 3 ปีที่แล้ว +3

    Pineapple 🍍😂 what an example 😂😂

    • @BMoDev
      @BMoDev  3 ปีที่แล้ว

      Lol made sense to me 🤷‍♂️

  • @AdversaryOne
    @AdversaryOne 3 ปีที่แล้ว +1

    Would there be a tweak in the script if I wanted a segmented health bar? Or would that all be done through the editor and art program (photoshop)?

  • @NoobNoob11037
    @NoobNoob11037 ปีที่แล้ว

    i typed out everything you did but it says that the comands i typed out are out dated. what do i do

  • @rahulvyas4020
    @rahulvyas4020 ปีที่แล้ว

    How would you do it if the death animation transition is in any state? And there is a parameter that Health If reaches zero, it should trigger the death animation? In a 3D game. I'm stuck at coding for health

    • @BMoDev
      @BMoDev  ปีที่แล้ว

      You could check in code if your health is 0 and then do something like animator.Play(deathAnimation.name)
      Where deathAnimation is an AnimationClip variable

  • @someonewithbadgrammer6740
    @someonewithbadgrammer6740 ปีที่แล้ว

    Can i get Farcry or Tarkov style healing system?
    It would be really cool you know.

  • @ellaroselyn4909
    @ellaroselyn4909 2 ปีที่แล้ว

    My health bar doesn’t show up when i press play? I have a main menu too. Help?

  • @jappyproductions4429
    @jappyproductions4429 3 ปีที่แล้ว +5

    I get an error that says: ‘Health.TakeDamage(int)’ is inaccessible due to its protection level. Why is this?
    Edit: I fixed this by changing the void takedamage to public

    • @BMoDev
      @BMoDev  3 ปีที่แล้ว +4

      Nice job figuring it out!

    • @FrostyDH
      @FrostyDH 2 ปีที่แล้ว

      @SynthWave Dave I followed the tutorial and got it working fine. Seems like you're a little incompetent

    • @ProdbyHway
      @ProdbyHway ปีที่แล้ว +1

      @@FrostyDH 😂😂 ur mean

  • @GGFallenWarrior
    @GGFallenWarrior 3 ปีที่แล้ว

    Can you make a video on how to make a stamina bar?

  • @DoxX069
    @DoxX069 ปีที่แล้ว

    what is the healthComponent though

  • @barghest8763
    @barghest8763 3 ปีที่แล้ว

    what extension did you use for untiy game on vscode?

  • @Aether241
    @Aether241 11 หลายเดือนก่อน

    How wpuld you add a hurt animation, like if you take damage and your're not dead. Send help

    • @BMoDev
      @BMoDev  10 หลายเดือนก่อน

      Id add an animation to my animator and tell my animator to play it when my players health is reduced

    • @Aether241
      @Aether241 10 หลายเดือนก่อน

      Thanks yo

  • @GamingGables
    @GamingGables 2 ปีที่แล้ว

    Not sure why, but my health bar goes down when I manually change my current health in the inspector. However, when using the OnTriggerEnter2D method the current health value still goes down, but the health bar image doesn’t actually change. Anyone know why this might be?

  • @ZotaEdits
    @ZotaEdits ปีที่แล้ว

    it doesnt show the max health and current health below the script even though i entered it properly

    • @SilverSwordCreative
      @SilverSwordCreative ปีที่แล้ว

      I had the same problem, make sure to add a semicolon wherever he does.

  • @animesongs3992
    @animesongs3992 ปีที่แล้ว

    im getting null refence error on collision

  • @isitsou
    @isitsou 3 ปีที่แล้ว

    Great video, very helpful! I would like to ask something. When you take the "health component" of the collision at th-cam.com/video/vNL4WYgvwd8/w-d-xo.html you assign it on type "var"... why is that? shouldnt you have assign it as type of "Health"???
    I am new to this and I try to understand what-goes-where...
    thanks again for the video!

    • @김지훈-g2d2t
      @김지훈-g2d2t 3 ปีที่แล้ว +2

      There is no specific reason for using var. You can use var any time that the initialization of the variable clearly tells what the variable will contain.

  • @bigp0y
    @bigp0y 3 ปีที่แล้ว +2

    What happened, Bmo? 3 pineapples max? Shame
    Great vid btw

    • @BMoDev
      @BMoDev  3 ปีที่แล้ว +1

      Lets see you do better 🙄

  • @acrow4969
    @acrow4969 8 หลายเดือนก่อน

    it did i was haing trouble cause i didnt know howto make it so other scripts could dmg their tarwgts i though t y was abig deal wiith tags and things

    • @acrow4969
      @acrow4969 8 หลายเดือนก่อน

      i reallize i have no context for "it did" you said "did that clear it up", it did... sorry

  • @blairmoore4424
    @blairmoore4424 3 ปีที่แล้ว

    Please do respawn

  • @Cleevor
    @Cleevor 2 ปีที่แล้ว

    lol

  • @subwaye
    @subwaye 3 ปีที่แล้ว +1

    first

    • @BMoDev
      @BMoDev  3 ปีที่แล้ว +2

      Mac Aaris beat you 😞

    • @syedmoin7939
      @syedmoin7939 3 ปีที่แล้ว

      @@BMoDev can you mobile fps tutorial

  • @sansunnec
    @sansunnec 2 ปีที่แล้ว

    had a streak for about 1 year... thy.
    u lost!

  • @sajjadbaradaran6307
    @sajjadbaradaran6307 2 ปีที่แล้ว

    So I have a TakeDamage() function just like yours. At the moment I'm using this function to scale down my Fill (health bar UI image). I also have four different GameObjects, each with a Collider, and an OnMouseDown function which returns { this.Collider.isTrigger = true; }. Let's say that I want all four GameObjects to be clicked (in my case, since the game's a mobile game, touched) and after they're clicked, apply TakeDamage(). So I have created another script and attached it to an empty game object, and in it, I called all the GameObject.Colliders.isTrigger and put them in an If() statement like this:
    public void FixedUpdate()
    {
    if(GameObject1.Colliders.isTrigger && GameObject2.Colliders.isTrigger ... == true)
    {
    TakeDamage(20);
    }
    }
    but whenever I run the program, instead of reducing only 20 from health, and show currentHealth as 80, it completely reduces the currentHealth down to 0!
    Basically, TakeDamage Works, if I'm using an If statement with a parameter of input.KeyDown function in Update, but if I use a bool in the If statment's parameter (like the example above), it doesn't work as it is supposed to.
    Can you help me?

    • @HornyAxolotl
      @HornyAxolotl 3 หลายเดือนก่อน

      I know its been over 2 years but while doing this I had the same error instead of doing a void in the health.cs just make it public like this:
      public void TakeDamage(int amount)
      {
      currentHealth -= amount;
      if(currentHealth maxHealth)
      {
      TakeDamage(amount);
      }
      }
      and now you can edit it from other scripts

  • @DeathIsSelf
    @DeathIsSelf ปีที่แล้ว

    players current health does reset between playtests (and keeps last playtest value). but when the player get hit the value of currentHealth goes back to last playtest. any ideas?