How to Make A Simple HEALTH SYSTEM in Unity

  Рет қаралды 62,844

BMo

BMo

Күн бұрын

Пікірлер: 72
@TegridyMadeGames
@TegridyMadeGames 3 жыл бұрын
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 жыл бұрын
Really cool to hear this, thanks!
@TegridyMadeGames
@TegridyMadeGames 3 жыл бұрын
@@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 5 ай бұрын
@@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
@thediodoin1000
@thediodoin1000 2 жыл бұрын
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
@deadbroadcastpc
@deadbroadcastpc 3 жыл бұрын
I like your explanation man, very entertaining
@IceCream-sb7lc
@IceCream-sb7lc 3 жыл бұрын
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 жыл бұрын
3 pineapples a day keeps the doctor away ;) I understand health now!
@BMoDev
@BMoDev 3 жыл бұрын
Thats right, stick with me I'll show you the truth
@lightningcode1136
@lightningcode1136 3 жыл бұрын
Yes! I could not find this in a Brackeys tutorial
@xioned
@xioned 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!
@LordBinzVR
@LordBinzVR 3 жыл бұрын
Simple and easy. Excellent tutorial!
@ASTARH
@ASTARH Жыл бұрын
hey i know im 2 years late but what is a health component
@eileeng2492
@eileeng2492 3 жыл бұрын
Great! Examples so good!
@BMoDev
@BMoDev 3 жыл бұрын
Thanks! 😃
@KagamiFr
@KagamiFr 3 ай бұрын
BRO I LOVE YOU SO MUCH
@wstevegaming593
@wstevegaming593 3 жыл бұрын
Why do the arrows kill him if he's wearing full plate
@lordkakabel76
@lordkakabel76 3 жыл бұрын
I died... laughing! 😂
@uncyan
@uncyan 3 жыл бұрын
your video is very Easy to understand so I wish there were Korean subtitles. cuz im korean
@BMoDev
@BMoDev 2 жыл бұрын
Me too, if i ever make real money off the channel ill invest in subtitle translators
@akizuki2971
@akizuki2971 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!
@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 жыл бұрын
Its all attitude, programming is 90% frustration, 10% elation. Approaching problems as simple hurdles will do much for your long term interest in programming.
@andrewislastyear1118
@andrewislastyear1118 3 жыл бұрын
Best prequel
@oedhelsetren
@oedhelsetren 2 жыл бұрын
Something I've tried is not creating add and subtract methods. All methods are additive, the values can be negative.
@macaaris1018
@macaaris1018 3 жыл бұрын
Pineapple 🍍😂 what an example 😂😂
@BMoDev
@BMoDev 3 жыл бұрын
Lol made sense to me 🤷‍♂️
@revmatch6r
@revmatch6r 3 жыл бұрын
Better hope I'm not around when you only have one pineapple left ⚰
@BMoDev
@BMoDev 3 жыл бұрын
😤😤
@shidou2380
@shidou2380 11 ай бұрын
im so confused, it has part or can follow from one video tutorial?
@jappyproductions4429
@jappyproductions4429 3 жыл бұрын
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 жыл бұрын
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 Жыл бұрын
@@FrostyDH 😂😂 ur mean
@macaaris1018
@macaaris1018 3 жыл бұрын
Great video 👍
@BMoDev
@BMoDev 3 жыл бұрын
Thanks 🙏
@hologrammaster2468
@hologrammaster2468 2 жыл бұрын
THANK YOU
@bigp0y
@bigp0y 3 жыл бұрын
What happened, Bmo? 3 pineapples max? Shame Great vid btw
@BMoDev
@BMoDev 3 жыл бұрын
Lets see you do better 🙄
@AdversaryOne
@AdversaryOne 3 жыл бұрын
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)?
@THEWHITEGLOW07
@THEWHITEGLOW07 8 ай бұрын
people: use this to make health bars... Me: Uses this to make a spam button...
@ellaroselyn4909
@ellaroselyn4909 2 жыл бұрын
My health bar doesn’t show up when i press play? I have a main menu too. Help?
@NoobNoob11037
@NoobNoob11037 Жыл бұрын
i typed out everything you did but it says that the comands i typed out are out dated. what do i do
@GGFallenWarrior
@GGFallenWarrior 2 жыл бұрын
Can you make a video on how to make a stamina bar?
@someonewithbadgrammer6740
@someonewithbadgrammer6740 Жыл бұрын
Can i get Farcry or Tarkov style healing system? It would be really cool you know.
@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
@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.
@Aether241
@Aether241 10 ай бұрын
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
@animesongs3992
@animesongs3992 Жыл бұрын
im getting null refence error on collision
@DoxX069
@DoxX069 Жыл бұрын
what is the healthComponent though
@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
@barghest8763
@barghest8763 3 жыл бұрын
what extension did you use for untiy game on vscode?
@isitsou
@isitsou 3 жыл бұрын
Great video, very helpful! I would like to ask something. When you take the "health component" of the collision at kzbin.info/www/bejne/rH-vZYqPnNuqmpo 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 жыл бұрын
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.
@blairmoore4424
@blairmoore4424 3 жыл бұрын
Please do respawn
@Cleevor
@Cleevor 2 жыл бұрын
lol
@subwaye
@subwaye 3 жыл бұрын
first
@BMoDev
@BMoDev 3 жыл бұрын
Mac Aaris beat you 😞
@syedmoin7939
@syedmoin7939 3 жыл бұрын
@@BMoDev can you mobile fps tutorial
@sansunnec
@sansunnec Жыл бұрын
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 2 ай бұрын
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?
Make an Easy 3D Game, Roll a Damn Ball in Unity
12:48
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,2 МЛН
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 182 МЛН
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59
Don't underestimate anyone
00:47
奇軒Tricking
Рет қаралды 21 МЛН
How to make a HEALTH BAR in Unity!
21:06
Brackeys
Рет қаралды 1,1 МЛН
How to make a Health System | Unity Tutorial
11:53
Code Monkey
Рет қаралды 182 М.
Unity Player Health and Health bar Tutorial
10:52
MoreBBlakeyyy
Рет қаралды 21 М.
I Made A Platformer Game But You're The Enemy
6:12
BMo
Рет қаралды 634 М.
I Made A Difficult Game About Climbing
15:04
Pontypants
Рет қаралды 2,2 МЛН
Easy Heart Health System in Unity
16:03
BMo
Рет қаралды 20 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 731 М.
How to make YOUR dream game with no experience
11:31
BinzuDev
Рет қаралды 1,6 МЛН
Making a Souls Like In A Month
15:32
Emis
Рет қаралды 985 М.
My Scratch game got 1,000,000 views so I made another one
7:36
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 182 МЛН