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 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
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
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
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!
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
Its all attitude, programming is 90% frustration, 10% elation. Approaching problems as simple hurdles will do much for your long term interest in programming.
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
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
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
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?
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!
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.
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?
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
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?
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!
Really cool to hear this, thanks!
@@BMoDev i made a free game coming to steam soon using your 5 min pong tutorial too xD
No, thank you!
@@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
I like your explanation man, very entertaining
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
Yes! I could not find this in a Brackeys tutorial
That intro, I now want some pineapple.. and health care. More importantly pineapple though lol. Solid tutorial BMo!
🍍 rum & pineapple is the truth #trust
3 pineapples a day keeps the doctor away ;) I understand health now!
Thats right, stick with me I'll show you the truth
Simple and easy. Excellent tutorial!
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
Awesome, glad it helped out!
Great!
Examples so good!
Thanks! 😃
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!
Wow means alot. Thanks!
I died... laughing! 😂
BRO I LOVE YOU SO MUCH
Best prequel
Great video 👍
Thanks 🙏
hey i know im 2 years late but what is a health component
Why do the arrows kill him if he's wearing full plate
Better hope I'm not around when you only have one pineapple left ⚰
😤😤
im so confused, it has part or can follow from one video tutorial?
your video is very Easy to understand
so I wish there were Korean subtitles. cuz im korean
Me too, if i ever make real money off the channel ill invest in subtitle translators
THANK YOU
people: use this to make health bars...
Me: Uses this to make a spam button...
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
Its all attitude, programming is 90% frustration, 10% elation. Approaching problems as simple hurdles will do much for your long term interest in programming.
Something I've tried is not creating add and subtract methods. All methods are additive, the values can be negative.
Pineapple 🍍😂 what an example 😂😂
Lol made sense to me 🤷♂️
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)?
i typed out everything you did but it says that the comands i typed out are out dated. what do i do
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
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
Can i get Farcry or Tarkov style healing system?
It would be really cool you know.
My health bar doesn’t show up when i press play? I have a main menu too. Help?
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
Nice job figuring it out!
@SynthWave Dave I followed the tutorial and got it working fine. Seems like you're a little incompetent
@@FrostyDH 😂😂 ur mean
Can you make a video on how to make a stamina bar?
what is the healthComponent though
what extension did you use for untiy game on vscode?
How wpuld you add a hurt animation, like if you take damage and your're not dead. Send help
Id add an animation to my animator and tell my animator to play it when my players health is reduced
Thanks yo
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?
it doesnt show the max health and current health below the script even though i entered it properly
I had the same problem, make sure to add a semicolon wherever he does.
im getting null refence error on collision
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!
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.
What happened, Bmo? 3 pineapples max? Shame
Great vid btw
Lets see you do better 🙄
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
i reallize i have no context for "it did" you said "did that clear it up", it did... sorry
Please do respawn
lol
first
Mac Aaris beat you 😞
@@BMoDev can you mobile fps tutorial
had a streak for about 1 year... thy.
u lost!
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?
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
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?