3 UNIQUE Health Bar Damage Taken Effects (Unity Tutorial)

Поделиться
HTML-код
  • Опубликовано: 8 ноя 2024

Комментарии • 93

  • @mreverything7056
    @mreverything7056 5 лет назад +66

    Brackeys, Blackthornprod, and Code Monkey are my Holy Trinity of Unity Tutorials

    • @ozguroz5340
      @ozguroz5340 4 года назад +1

      and N3K

    • @GymCritical
      @GymCritical 4 года назад +6

      RIP Brackeys

    • @mreverything7056
      @mreverything7056 4 года назад +2

      Excelsius Studios Fuck, you saw too

    • @KalponicGames
      @KalponicGames 3 года назад +1

      Nah you need only code monkey for clean code. Pod or brackeys are for kids who just wanna play.

    • @MarushiaDark316
      @MarushiaDark316 3 года назад +2

      I would add Lost Relic Games to that list.

  • @BlackHayateMX
    @BlackHayateMX 5 лет назад +3

    Love your tutorials! And I love the way you speed up the video during the boring parts XD ❤❤❤

  • @Ionixification
    @Ionixification 2 года назад

    I cannot believe youve even made this tutorial. No matter what I search your channel comes up. Unreal.

  • @diegosuarez5473
    @diegosuarez5473 5 лет назад +7

    Broh, you're a really crack... keep going and congratulations broh!!

  • @MarushiaDark316
    @MarushiaDark316 3 года назад +7

    I could easily see this working in reverse for incremental healing as well.

  • @danielmakac3686
    @danielmakac3686 5 лет назад

    Awesome! CodeMonkey! The best as always.

  • @IOSoraOI
    @IOSoraOI 5 лет назад +2

    I love you Code Monkey I've been trying to do this for so long

  • @-lunte.
    @-lunte. 2 года назад

    for the 2nd bar add if (damagedHealthShrinkTimer

  • @mohamedessam-6228
    @mohamedessam-6228 5 лет назад +1

    keep going on, you'r the best.

  • @Noss454
    @Noss454 4 года назад +1

    Quality content. Congratulations ^^

  • @ozguroz5340
    @ozguroz5340 4 года назад +1

    best coder ever

  • @diamondthrust2019
    @diamondthrust2019 5 лет назад

    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 ?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад

      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.

  • @louisecollins9213
    @louisecollins9213 2 года назад

    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.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 года назад

      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

  • @kantallive
    @kantallive 5 лет назад +1

    That's what I was searchin' for

  • @kamski3070
    @kamski3070 5 лет назад

    very nice video code Bro !

  • @CodeMonkeyUnity
    @CodeMonkeyUnity  5 лет назад +1

    🤖Join the Community Discord discord.gg/eHjUVrm

  • @RLPlays
    @RLPlays 5 лет назад

    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!

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +1

      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.

  • @jackheller2470
    @jackheller2470 4 года назад +1

    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.

  • @symbiote_ZZ
    @symbiote_ZZ 4 года назад +1

    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."

  • @AxZelAnimations30
    @AxZelAnimations30 2 года назад

    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.

    • @Gamer-df6if
      @Gamer-df6if 11 месяцев назад

      Usually the damage fill stops decreasing for some time after getting hit before it decreases again.
      Many video games use this.

  • @nightyonetwothree
    @nightyonetwothree 4 года назад

    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?

  • @afropenguinproductions4628
    @afropenguinproductions4628 11 месяцев назад

    Hey CodeMonkey! How can I make it so that the Cut Bar falls as one merged piece?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  11 месяцев назад

      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

    • @afropenguinproductions4628
      @afropenguinproductions4628 11 месяцев назад

      @@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.

  • @tprim4495
    @tprim4495 5 лет назад +1

    i get warning at HealthBarFade at line 19
    *healthSystem = new EnemyHealth1(100);*
    "You are trying to create a MonoBehaviour using the 'new' keyword"

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад

      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.

  • @incpwnge
    @incpwnge 5 лет назад

    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.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад

      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.

    • @incpwnge
      @incpwnge 5 лет назад

      @@CodeMonkeyUnity I mean that with the same health bar prefab you have a health bar on every unit.

  • @johnminervn
    @johnminervn 3 года назад

    health bar cut drop:
    18:10

  • @random_precision_software
    @random_precision_software 5 лет назад

    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?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад

      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

    • @random_precision_software
      @random_precision_software 5 лет назад

      @@CodeMonkeyUnity ok TY

  • @krakendoom9946
    @krakendoom9946 5 лет назад

    Prooooo😍😍😍

  • @notDiru
    @notDiru 4 года назад

    Is it viable with Slider bars instead of sprite bars?

    • @notDiru
      @notDiru 4 года назад

      And I Can't use healthsystem.Damage(X); dunno what's the code to call that from another script but it aint working.

  • @alexhp1282
    @alexhp1282 5 лет назад

    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).

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад

      You're trying to access something that is set to null.

    • @alexhp1282
      @alexhp1282 5 лет назад +1

      Code Monkey I know, but I don’t know what

  • @tomicooltomi
    @tomicooltomi 5 лет назад

    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.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +2

      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.

  • @CRSRCS-lm8ok
    @CRSRCS-lm8ok 4 года назад +1

    Like the Vids but wayyyyy too many ads on other channels :-|

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 года назад

      I limit the number of impressions/views so you should be seeing at most 4-5 per week. How many are you seeing?

    • @CRSRCS-lm8ok
      @CRSRCS-lm8ok 4 года назад

      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.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 года назад

      @@CRSRCS-lm8ok Yes just double click to open the package in Unity, make sure you're using 2018.3.1 or later

  • @fasttaekwondo9426
    @fasttaekwondo9426 4 года назад

    Lmao...i got your ad's in your video

  • @theridiculouschannel7017
    @theridiculouschannel7017 4 года назад

    I get an error... Cannot implicitly convert type UnityEngine.Color to UnityEngine.UI.Image

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 года назад

      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;

  • @Thesupperals
    @Thesupperals 3 года назад

    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.

  • @ВладикГагаринов
    @ВладикГагаринов 5 лет назад

    How you learned this?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад

      Unity and C#? Just experience over many years.
      Keep doing things and you will constantly get better!

  • @diegosuarez5473
    @diegosuarez5473 5 лет назад

    Do same, but with numbers like at mario

  • @djferg94
    @djferg94 4 года назад

    Newer versions of Unity don't let you add MonoBehaviours using the "new" keyword. Because of this I can't use the method shown.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 года назад

      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?

    • @djferg94
      @djferg94 4 года назад

      @@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
      @CodeMonkeyUnity  4 года назад +1

      @@djferg94 The HealthSystem Class does not extend MonoBehaviour

  • @Pixch
    @Pixch 5 лет назад

    Do this with shaders..

  • @Cloxygen
    @Cloxygen 4 года назад

    what happens if you take damage while the fade has already started?

    • @MarushiaDark316
      @MarushiaDark316 3 года назад

      It should retrigger the OnDamaged event and run that code again, which just checks whether or not the bar is visible.

  • @ehsanafzal185
    @ehsanafzal185 5 лет назад

    how to make a duplicate copy of C# Script.
    ctrl+c and Ctrl+v cant working.

  • @bluelixn1001
    @bluelixn1001 4 года назад

    When you don't know if he is that fast typing or he just speed it up.

  • @slezy-1983
    @slezy-1983 4 года назад +1

    why does no one show how to use colliders to lower or increase health with a slider hp bar, PLEASE MAKE ONE!

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 года назад

      I've covered Colliders here ruclips.net/video/Bc9lmHjqLZc/видео.html
      And a Health System here ruclips.net/video/0T5ei9jN63M/видео.html

  • @RoleOfQuarters
    @RoleOfQuarters 5 лет назад

    i'm sorry couldn't finish your tutorial you skipped over the adding image part and i cant figure out

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +1

      What adding image part? At 1:58 you can see the Transform hierarchy with the background and the bar image.

    • @RoleOfQuarters
      @RoleOfQuarters 5 лет назад

      @@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

  • @iluWinter
    @iluWinter 4 года назад +1

    This doesn't work in newest version of unity - even the file you included doesn't work.

  • @turboplays_fortnite1244
    @turboplays_fortnite1244 4 года назад

    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

  • @shivbajpai3826
    @shivbajpai3826 5 лет назад

    bro you are a realy good game dev but you don't explain things properly. Try going slow like Brackeys.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +1

      What didn't you understand?

    • @shivbajpai3826
      @shivbajpai3826 5 лет назад

      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.

    • @shivbajpai3826
      @shivbajpai3826 5 лет назад

      Which is fine if you are making videos for Intermediate Coders

  • @killingtech9514
    @killingtech9514 5 лет назад

    2nd comment

  • @Ionixification
    @Ionixification 2 года назад

    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;