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!
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.
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
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
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
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.
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.
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. !
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.
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...?
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).
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.
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.
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
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
This is like the reincarnation of Brackeys... easy to understand, follow and build upon. Thank you!
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!
Thats a big compliment! thanks
Bmo videos have single handedly dropped my cholesterol and now my heart is healthy ❤️
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.
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!!
wooo lets gooo, make a masterpiece I'm always looking for something fun
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.
Sick video! Very helpful!
Thank you for the clear tutorial and explanation
Much appreciated
Bro very much thank you I literally was stuck on this problem for 3 days
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
haha typical - appreciate it!
Great video! helped a lot
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
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
can you explain a liittle bit of this OnPlayerDamaged event ?
because i only using
health = health - 1
every time it taking damage
Please a new and improved 2d top down movement tutorial
HElpful thx
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.
Nvm it somehow works now.
So what would we do if we wanted each heart to only be one health
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.
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. !
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.
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...?
Anybody know my it won't let me assign my player to the player health
THANK YOU!!!!!!!!
Thank you
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 :(
I like this, but please don't spawn in stuff without notice, like code and such
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?
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).
@@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
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?
How do you get this to work if you are using public health and maxHealth floats within the HealthHeartManager script?
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.
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.
ı love you
how do i make a script if i want each enemy type to have different damage?
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
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
Holllaaa
doesn't work :l
pm me script pleash
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;
}
}
}
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
thats not how that works you can still do that for 3d