Right now i am learning javascript i can’t wait to learn c++ and c# to try making these games btw do you have any tutorials with javascript related to games ?
Looking forward to starting the Term Based Strategy Tutorial. Where could I find an Outline script ? I tried using one in the lastest version of Unity but it comes out solid. I mean looks ok but look better if was just black outline.
The UI outline script? It's the one built into Unity, I don't think you even need to install any package, I think it's there by default You can play with the color alpha if you want a solid outline or not If you want a shader outline for non-UI elements I made one here unitycodemonkey.com/video.php?v=FvQFhkS90nI
Hey Code Monkey, it's best to use an object like you used for the health system to deal with health, or use a different script or even just use a simple variable and some methods in the main character class? Thanks for the great video man! Congratz!
You should keep your health system in its own separate class and your player and whatever else needs to have health simply holds an instance of that class. That will help keep your code organized.
Hi, if i want to keep the current health value to the next level, what is the best way to do so? Since i has been able to store that value but the constructor gets called at every new level so the value is somehow just like a ghost value.
My damage button is working, but not my heal button. At the line where I get the component for my heal button, Unity says "NullReferenceException: Object reference not set to an instance of an object."
So technique is indeed to make a 2nd image under the main HealthFill. My only problem is if you get hit while the damage fill is decreasing. Gonna try this later and see it for myself.
if i want use same healthbar for different units (like in wow/other mmorpg where you can select only one target = one healthbar), then event subscription will be a problem?
You would need to add some logic to merge the slices if multiple slices hadn't fallen yet. Basically destroy one and change the size of the other one to match both
@@CodeMonkeyUnity I think I got it! I just added the HealthBarCut Script to my damagedBarTemplate, then instead of Add Component, I use GetComponent.cutimer = 1 on Damage, and in the Health Cut Timer>Update, I check if the CutTimer is ever greater than 0, then proceed to countdown, when it reaches 0, slide, fade, and destroy.
You cannot "new" MonoBehaviours. If you don't need the MonoBehaviours functions just don't inherit MonoBehaviour. If you do need the functions, you can just make a public void Setup(); function where you do whatever you would do in the constructor.
Hey. In one of your previous healthbar video you created its prefab, and deleted from the scene. I donwloaded the project and saw there a game object named GameAssests. I saw 4 different prefabs for whole project; enemy transform, player transform, health bar, and sword slash. All the moving game objects had their own health bar on top of their head. I tried to run through your codes but they were extremely complicated for my level. I wonder how you managed to do with a single type of prefab and a script. Because the enemy prefabs and the player prefab have only their type scripts on them. Will you make a tutorial about sorting never ending enemies' health bars? Or is it some sort of your signature and secret? Thanks for the tutorials by the way.
Are you asking how the visuals are set up? The prefabs are indeed mostly empty since the animation system works through code, the mesh is dynamically generated. So there isn't a game object skeleton directly on the prefab. For the health bar sorting you can just put it on a very high number like 10,000 and it will show up on top of everything.
No haven't covered the persistent particle effect yet, it's on my to-do list. But you can look at the source code in the project files, it's not too complicated You have the Blood_Handler.cs which spawns the particles and the Generic_Mesh_Script.cs which dynamically creates the mesh to display them. In the Scene check the game object GameHandler/Meshes/Mesh_Blood
I’m having an error that says NullReferenceException: Object reference not set to an instance of an object HealthBarFade.HealthSystem_OnDamaged, do u know how to solve it, and why it’s saying that (if I click on it, it brings me on line 32).
Using Find or dragging the reference is a matter of personal preference. They both have pros and cons. Dragging the reference can break if you modify the editor hierarchy and using Find can break if you rename or move it. Personally I prefer to keep as much through code as possible so for all children references I use Find.
2 per day but I watch a ton of vids and ur ads are the only ones that my ad blocker doesn't block so.... Also I am having trouble with the unity game package I can't seem to open it? Am I not supposed to open it? In ref to project files.
You cannot convert a Color directly into an Image, those are completely different types. Are you trying to apply a color to an image? Then do image.color = color;
There is something that is bothering me. I'm trying to do a customized health bar. They are keys of a piano. I need each of these images to represent a value of 1. So if the enemy has 88 health, I'll have 88 keys or 88 images. The insane problem at hand and that I keep encountering is the idea that I am not allowed to. I need this so I can have a correct representation of the image. I've been told that Unity will malfunction & as a noob, I can't really chance that in my first project 3 years in.
@@CodeMonkeyUnity 7:07 healthSystem = new HealthSystem(100);, line 20. I get the error "You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all UnityEngine.MonoBehaviour:.ctor()"
@@CodeMonkeyUnity what i mean is you just put it on either without explaining or not explainig good enough and i'm to dumb to figure out what happened, i really apreciate when the creater of the video responds i'm trying to figure out how to put a hud into vrchat
You don't mention things like why are you using a private or public variable, how are you referencing the health bar etc. I think your content is not beginner-friendly. Sorry if I'm being rude.
I guess with constant 1f fading speed, having higher HP slider values would not scale, or the fading would become slow no? Quick hack I use now: BossHPFadeSlider.value -= (BossHPSlider.maxValue / 10) * Time.deltaTime;
Brackeys, Blackthornprod, and Code Monkey are my Holy Trinity of Unity Tutorials
and N3K
RIP Brackeys
Excelsius Studios Fuck, you saw too
Nah you need only code monkey for clean code. Pod or brackeys are for kids who just wanna play.
I would add Lost Relic Games to that list.
Love your tutorials! And I love the way you speed up the video during the boring parts XD ❤❤❤
I cannot believe youve even made this tutorial. No matter what I search your channel comes up. Unreal.
I'm glad the videos helped you!
Broh, you're a really crack... keep going and congratulations broh!!
I could easily see this working in reverse for incremental healing as well.
Awesome! CodeMonkey! The best as always.
I love you Code Monkey I've been trying to do this for so long
for the 2nd bar add if (damagedHealthShrinkTimer
keep going on, you'r the best.
Quality content. Congratulations ^^
best coder ever
Right now i am learning javascript i can’t wait to learn c++ and c# to try making these games btw do you have any tutorials with javascript related to games ?
Don't have anything on Javascript. The good thing is all those languages are pretty similar so if you know one you can easily learn the rest.
Looking forward to starting the Term Based Strategy Tutorial. Where could I find an Outline script ? I tried using one in the lastest version of Unity but it comes out solid. I mean looks ok but look better if was just black outline.
The UI outline script? It's the one built into Unity, I don't think you even need to install any package, I think it's there by default
You can play with the color alpha if you want a solid outline or not
If you want a shader outline for non-UI elements I made one here unitycodemonkey.com/video.php?v=FvQFhkS90nI
That's what I was searchin' for
very nice video code Bro !
🤖Join the Community Discord discord.gg/eHjUVrm
Hey Code Monkey, it's best to use an object like you used for the health system to deal with health, or use a different script or even just use a simple variable and some methods in the main character class? Thanks for the great video man! Congratz!
You should keep your health system in its own separate class and your player and whatever else needs to have health simply holds an instance of that class. That will help keep your code organized.
Hi, if i want to keep the current health value to the next level, what is the best way to do so? Since i has been able to store that value but the constructor gets called at every new level so the value is somehow just like a ghost value.
My damage button is working, but not my heal button. At the line where I get the component for my heal button, Unity says "NullReferenceException: Object reference not set to an instance of an object."
So technique is indeed to make a 2nd image under the main HealthFill.
My only problem is if you get hit while the damage fill is decreasing. Gonna try this later and see it for myself.
Usually the damage fill stops decreasing for some time after getting hit before it decreases again.
Many video games use this.
if i want use same healthbar for different units (like in wow/other mmorpg where you can select only one target = one healthbar), then event subscription will be a problem?
Hey CodeMonkey! How can I make it so that the Cut Bar falls as one merged piece?
You would need to add some logic to merge the slices if multiple slices hadn't fallen yet. Basically destroy one and change the size of the other one to match both
@@CodeMonkeyUnity I think I got it! I just added the HealthBarCut Script to my damagedBarTemplate, then instead of Add Component, I use GetComponent.cutimer = 1 on Damage, and in the Health Cut Timer>Update, I check if the CutTimer is ever greater than 0, then proceed to countdown, when it reaches 0, slide, fade, and destroy.
i get warning at HealthBarFade at line 19
*healthSystem = new EnemyHealth1(100);*
"You are trying to create a MonoBehaviour using the 'new' keyword"
You cannot "new" MonoBehaviours.
If you don't need the MonoBehaviours functions just don't inherit MonoBehaviour.
If you do need the functions, you can just make a public void Setup(); function where you do whatever you would do in the constructor.
Hey.
In one of your previous healthbar video you created its prefab, and deleted from the scene. I donwloaded the project and saw there a game object named GameAssests. I saw 4 different prefabs for whole project; enemy transform, player transform, health bar, and sword slash. All the moving game objects had their own health bar on top of their head. I tried to run through your codes but they were extremely complicated for my level.
I wonder how you managed to do with a single type of prefab and a script. Because the enemy prefabs and the player prefab have only their type scripts on them. Will you make a tutorial about sorting never ending enemies' health bars? Or is it some sort of your signature and secret?
Thanks for the tutorials by the way.
Are you asking how the visuals are set up? The prefabs are indeed mostly empty since the animation system works through code, the mesh is dynamically generated. So there isn't a game object skeleton directly on the prefab.
For the health bar sorting you can just put it on a very high number like 10,000 and it will show up on top of everything.
@@CodeMonkeyUnity I mean that with the same health bar prefab you have a health bar on every unit.
health bar cut drop:
18:10
I was looking thro your videos to see if there was one of blood spatter left on the floor after killing an enemy.. have you done one?
No haven't covered the persistent particle effect yet, it's on my to-do list.
But you can look at the source code in the project files, it's not too complicated
You have the Blood_Handler.cs which spawns the particles and the Generic_Mesh_Script.cs which dynamically creates the mesh to display them.
In the Scene check the game object GameHandler/Meshes/Mesh_Blood
@@CodeMonkeyUnity ok TY
Prooooo😍😍😍
Is it viable with Slider bars instead of sprite bars?
And I Can't use healthsystem.Damage(X); dunno what's the code to call that from another script but it aint working.
I’m having an error that says NullReferenceException: Object reference not set to an instance of an object HealthBarFade.HealthSystem_OnDamaged, do u know how to solve it, and why it’s saying that (if I click on it, it brings me on line 32).
You're trying to access something that is set to null.
Code Monkey I know, but I don’t know what
Why don't you make barImage public and reference it in the editor? I think this should be a lot more safe in case things get removed/renamed.
Using Find or dragging the reference is a matter of personal preference. They both have pros and cons.
Dragging the reference can break if you modify the editor hierarchy and using Find can break if you rename or move it.
Personally I prefer to keep as much through code as possible so for all children references I use Find.
Like the Vids but wayyyyy too many ads on other channels :-|
I limit the number of impressions/views so you should be seeing at most 4-5 per week. How many are you seeing?
2 per day but I watch a ton of vids and ur ads are the only ones that my ad blocker doesn't block so.... Also I am having trouble with the unity game package I can't seem to open it? Am I not supposed to open it? In ref to project files.
@@CRSRCS-lm8ok Yes just double click to open the package in Unity, make sure you're using 2018.3.1 or later
Lmao...i got your ad's in your video
I get an error... Cannot implicitly convert type UnityEngine.Color to UnityEngine.UI.Image
You cannot convert a Color directly into an Image, those are completely different types.
Are you trying to apply a color to an image?
Then do image.color = color;
There is something that is bothering me. I'm trying to do a customized health bar. They are keys of a piano. I need each of these images to represent a value of 1. So if the enemy has 88 health, I'll have 88 keys or 88 images. The insane problem at hand and that I keep encountering is the idea that I am not allowed to. I need this so I can have a correct representation of the image. I've been told that Unity will malfunction & as a noob, I can't really chance that in my first project 3 years in.
How you learned this?
Unity and C#? Just experience over many years.
Keep doing things and you will constantly get better!
Do same, but with numbers like at mario
Newer versions of Unity don't let you add MonoBehaviours using the "new" keyword. Because of this I can't use the method shown.
No version has ever let you do new on a MonoBehaviour, that's not a recent change.
Where are you seeing that happen in the video?
@@CodeMonkeyUnity 7:07 healthSystem = new HealthSystem(100);, line 20. I get the error "You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all
UnityEngine.MonoBehaviour:.ctor()"
@@djferg94 The HealthSystem Class does not extend MonoBehaviour
Do this with shaders..
what happens if you take damage while the fade has already started?
It should retrigger the OnDamaged event and run that code again, which just checks whether or not the bar is visible.
how to make a duplicate copy of C# Script.
ctrl+c and Ctrl+v cant working.
Ctrl+D
When you don't know if he is that fast typing or he just speed it up.
why does no one show how to use colliders to lower or increase health with a slider hp bar, PLEASE MAKE ONE!
I've covered Colliders here ruclips.net/video/Bc9lmHjqLZc/видео.html
And a Health System here ruclips.net/video/0T5ei9jN63M/видео.html
i'm sorry couldn't finish your tutorial you skipped over the adding image part and i cant figure out
What adding image part? At 1:58 you can see the Transform hierarchy with the background and the bar image.
@@CodeMonkeyUnity what i mean is you just put it on either without explaining or not explainig good enough and i'm to dumb to figure out what happened,
i really apreciate when the creater of the video responds
i'm trying to figure out how to put a hud into vrchat
This doesn't work in newest version of unity - even the file you included doesn't work.
What doesn't work?
In the start where it says "private Image barImage; " it gives me a warning and says type or namespace name "Image" could not be found
You need to add "using UnityEngine.UI;"
Thanks
bro you are a realy good game dev but you don't explain things properly. Try going slow like Brackeys.
What didn't you understand?
You don't mention things like why are you using a private or public variable, how are you referencing the health bar etc. I think your content is not beginner-friendly. Sorry if I'm being rude.
Which is fine if you are making videos for Intermediate Coders
2nd comment
I guess with constant 1f fading speed, having higher HP slider values would not scale, or the fading would become slow no?
Quick hack I use now:
BossHPFadeSlider.value -= (BossHPSlider.maxValue / 10) * Time.deltaTime;