MELEE COMBAT in Unity

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ม.ค. 2025

ความคิดเห็น •

  • @Danidev
    @Danidev 5 ปีที่แล้ว +3487

    Awesome video, and enjoy your holiday break! Looking forward to 2020 Brakcyes! :D

    • @jansasinowski7319
      @jansasinowski7319 5 ปีที่แล้ว +67

      What are you doing here dani haha

    • @Lazy4444
      @Lazy4444 4 ปีที่แล้ว +260

      You are here because you are going to do a 2D melee combat game...(or you cant do that?)

    • @vuleproduction443
      @vuleproduction443 4 ปีที่แล้ว +9

      Y e s

    • @crilein2425
      @crilein2425 4 ปีที่แล้ว +33

      Yes brakcyes, eeeh wait... BRAKCYES? 😂

    • @dvxv4016
      @dvxv4016 4 ปีที่แล้ว +10

      @@jansasinowski7319 He likes to see Brackeys videos

  • @orange1304
    @orange1304 5 ปีที่แล้ว +2319

    "He gets hurt and he dies. Awesome!"
    Damn, that's quite awkward out of context.

    • @AbirHasanDipu
      @AbirHasanDipu 5 ปีที่แล้ว +31

      Death is awesome. You should try it sometime.

    • @moric4677
      @moric4677 5 ปีที่แล้ว +10

      @@AbirHasanDipu as you have tried before

    • @apersonthatsucksatnames1133
      @apersonthatsucksatnames1133 5 ปีที่แล้ว +7

      out of context at 18:22

    • @salesman4396
      @salesman4396 5 ปีที่แล้ว +7

      @@snekpliskin Police will find out that there are multiple people involved as the word "lets" is used. Run !!

    • @acid3719
      @acid3719 4 ปีที่แล้ว

      1k th like:)

  • @descar1626
    @descar1626 5 ปีที่แล้ว +732

    "so, lets slice up some enemies"
    *slices himself*

    • @clivegrey8557
      @clivegrey8557 5 ปีที่แล้ว +42

      You think Brackeys is trying to send us some type of cryptic message??

    • @ZiRR0
      @ZiRR0 5 ปีที่แล้ว +4

      slies?

    • @QS1597
      @QS1597 5 ปีที่แล้ว +27

      You are your biggest enemy

    • @FreeD00M
      @FreeD00M 5 ปีที่แล้ว +7

      it was the view of the enemy...

    • @descar1626
      @descar1626 5 ปีที่แล้ว +6

      @@FreeD00M oh, shit, I'm sorry, you're right

  • @BujGames78
    @BujGames78 5 ปีที่แล้ว +556

    This has an issue tough . The overlap circle gets triggered exactly the moment we press attack button , and if we have a longer animation , we will miss all the enemys we want to hit . This happened to me but it can be fixed using Animation Events and simply put all the attack code except the animation trigger in a new public attack function and then call it from the animation at the right time. And then , in our code we just trigger the animation when we press the attack button . A great tutorial tough ! Love it

    • @csdiabo
      @csdiabo 5 ปีที่แล้ว +10

      This is actually a really good suggestion, thanks! :D

    • @paulwin9036
      @paulwin9036 5 ปีที่แล้ว +9

      You can us IEnumerator

    • @IInathanwhyII
      @IInathanwhyII 4 ปีที่แล้ว +8

      how? pls help or show code.

    • @g4ble
      @g4ble 4 ปีที่แล้ว +32

      @@paulwin9036 For the timing?
      I think using Animation Events is easier to set up and use, because you can actually see the animation while setting the event.

    • @silverchariot6321
      @silverchariot6321 4 ปีที่แล้ว +2

      you just made my day thank you so much!

  • @AlecAndersonZx
    @AlecAndersonZx 5 ปีที่แล้ว +59

    Wow the timing could not be more perfect I really needed this and all the other tutorials I found were low quality

    • @mattice9083
      @mattice9083 5 ปีที่แล้ว +1

      Ikr same. I'm working on a super Smash Bros game and just got working on the combat

    • @winterfallstudios7101
      @winterfallstudios7101 5 ปีที่แล้ว

      @@mattice9083is it a smash like game or a smash fan game?

    • @mattice9083
      @mattice9083 5 ปีที่แล้ว +1

      Meh more 2d fighter more similiar to towerfall but with sword combat and shurikens

  • @mccheong7288
    @mccheong7288 5 ปีที่แล้ว +373

    Hi, there are some in comment ask how to do combo attacks. So just thought to post my reply here (animator side only):
    There is actually a easy way to do that. In the animator, create an Idle State and your 3 attack States and a Boolean variable. Make each state a transition to Idle on condition the Boolean variable is False. Then also make transitions to link from one attack to another on condition the Boolean variable is True. Therefore as long as the State detect the Boolean is True it will play the sequence of attack. And if it detect a False, it will return to Idle state. However there are many ways on the input implementation side depending on your code. And also how the combo is execute like do the combo execute as long as the button is press 3 time or press on specific time or as long as button is depress. So I left it up to you.

    • @sharif47
      @sharif47 5 ปีที่แล้ว +7

      Wouldn't it be better to use an integer instead?
      That way, you can make sure only one value for attack animation will be valid at a time.
      Also, how about using a blend tree? (Even though the main purpose of a blend tree is too blend animations.)

    • @filipstudeny
      @filipstudeny 5 ปีที่แล้ว +4

      @@sharif47 I wouldn't recommend using blend tree.Since most of the time you want the attack animation to be played fully and blending attacking animations does look terrible and can cause lots of problems.
      if you have hitboxes that depend on the lenght of the attacking animations.
      For example 2) Sword hitbox getting activated on the start of the attacking animation and disabling on the end of the attacking animation, using blend tree you would have to create a system that reads data from the animator and sends it back to the player so that the hitbox gets activated/disabled at the right time.

    • @ramiroghilino4546
      @ramiroghilino4546 4 ปีที่แล้ว +4

      Hey, i'm interested in making a combo with 3 attacks, wich is the code i shloud add to make it (I have the things of your comment already)

  • @seaderwerks3046
    @seaderwerks3046 ปีที่แล้ว +18

    This took me way longer to figure out than it should of, but if you're having the issue where you can attack your enemy from one side, but not the other, its because the "attack point" circle is placed IN FRONT of your character. To fix this, move the attack point to the CENTER of your player model, and size the attack point around you. Where-ever that attack point circle touches, you can attack. hope this saves someone hours of googling and item searching. I only figured it out from watching another video. Hope this helps.

    • @madrain3941
      @madrain3941 ปีที่แล้ว

      can you tell me what the other videos title was? I'm struggling with this tutorial also.

    • @seaderwerks3046
      @seaderwerks3046 ปีที่แล้ว

      @@madrain3941 The video didn't address anything specifically with this tutorial. It was showing something else and I just happened to notice that there was a gizmo wrapped over the center of the player and thats how I figured it out. You can write a script that rotates the attack point with the player that will help with the player attack from only the right or attacking 'behind' you.

    • @ariweizman9041
      @ariweizman9041 ปีที่แล้ว

      holy thank you so much i was just struggling with that!

    • @migue4044
      @migue4044 ปีที่แล้ว +1

      But then you could attack enemies that are behind you right? Maybe theres a way to check wich side are you looking at, i have the same problem but didnt check if that would work or how could i do it, if you figured a better way to do it and you can tell me that would be really helpful

    • @seaderwerks3046
      @seaderwerks3046 ปีที่แล้ว

      @@migue4044 Yes! This was written when I was still learning more about this also.
      Eventually I found a way to make the attackpoint flip when the player does. So if the player was facing -1 then it would be facing the left, and if the player is facing 1, it goes to the right. Just plug them in with your Flip functions.
      You could also go to GPT and ask for a "offset" script that you can plug into your attackpoint gizmo and have it specifically positioned. so you can adjust the gizmos range on the X and Y.

  • @DenVosReinaert
    @DenVosReinaert 4 ปีที่แล้ว +50

    The beauty of starting out in Game Development, the awkward struggle to figure out something as simple as this, being frustrated, and then just happening to stumble upon a video like this. This video is great and makes things so much simpler than what I was trying to do, thank you.

    • @spacebrain1944
      @spacebrain1944 4 ปีที่แล้ว

      Literally same fucking thing *just* happened to me. So funny

  • @agustinquindimil6594
    @agustinquindimil6594 7 หลายเดือนก่อน +3

    BRO, YOU SAVED MY EXAM PRETTY MUCH, THIS HELPS ME SO MUCH

  • @brady1351
    @brady1351 5 ปีที่แล้ว +154

    Hey brackets, your channel has got me obsessed with learning how to code, I’m trying to find time to do it and I will watch all your tutorials.

    • @idk-iu8vn
      @idk-iu8vn 5 ปีที่แล้ว +9

      Anakin Skywalker his name is brackeys

    • @CreepyUncleIdjit
      @CreepyUncleIdjit 5 ปีที่แล้ว +3

      Definitely worth it, he is amazing at explaining how to create games of multiple genres in unity.

    • @qtnova6950
      @qtnova6950 5 ปีที่แล้ว +13

      Brackets👏👏👏

    • @ryzenpeak
      @ryzenpeak 4 ปีที่แล้ว +2

      @Fate I love how insults in game dev comments are like passive aggressive and almost inspirational, but in every other comments section its STFU STUPID. LOL

    • @The-Athenian
      @The-Athenian 4 ปีที่แล้ว

      No you won't lol

  • @joachimg7872
    @joachimg7872 5 ปีที่แล้ว +71

    Wow video came out exactly while I was having a problem doing this 😁

    • @2Asspie
      @2Asspie 5 ปีที่แล้ว +2

      same lol

  • @shanesawyer3391
    @shanesawyer3391 2 ปีที่แล้ว +2

    I’ve watched a lot of TH-cam videos and series on scripting and Unity. This channel is by far the best, and most effective way to genuinely learn that I’ve come across.

  • @BaronVonScrub
    @BaronVonScrub 3 ปีที่แล้ว +7

    Unless I completely missed something, I think there's something skipped over in the tutorial?
    Attack() is called on space being pressed, which should on that same frame immediately find the collisions and output the debug/damage.
    What is shown is a delay with the attack windup before the strike occurs, instead.

  • @LeooAi
    @LeooAi 5 ปีที่แล้ว +14

    u guys can run the attack function in a animation event if u want timing with your attack animations but u have to to play the animation when u press the key and remove the attack function from there because its gonna run in the animation :D

    • @MinhocaMortifera
      @MinhocaMortifera 5 ปีที่แล้ว

      Yeah, I make it too. 😁

    • @aquaarmour4924
      @aquaarmour4924 5 ปีที่แล้ว +5

      This one of the only helpful comments in this brain-dead comment section.

    • @LeooAi
      @LeooAi 5 ปีที่แล้ว

      Aqua Armour thanks 😅

  • @HectorMendoza2001
    @HectorMendoza2001 4 ปีที่แล้ว +3

    I see at least a few people asked about flipping the attack point. Since I bet moving the character to the left is just an X-flip of the animation, the attack point stays to the right of the player all the time (this being in my view a bug). My recommendation would be to do some vector math from the center point of the character while taking into account the direction the character is facing. You can easily store these vectors in a variable and tie them to your controls. This is not saying this video is not AWESOME and SUPER HELPFUL as everything else Brackeys does. THANKS BRACKEYS!

  • @zjin_99
    @zjin_99 หลายเดือนก่อน

    this is awesome! this is exactly what i needed. so many other people used raycast or something else that basically only hit one enemy, which doesn't really accomplish what i want for slashing that may hit multiple enemies

  • @VeNoM0619
    @VeNoM0619 5 ปีที่แล้ว +19

    Just a note, if you are doing 3d from a first person perspective, you don't want to sphere cast.
    Just a ray cast with a maximum distance, or simply attach a simple collider to the weapon you are using and check for collision on that as trigger only.

    • @narakko_xd
      @narakko_xd 7 หลายเดือนก่อน

      thanks man! I was trying to get it working for 1 hour in 3d

  • @redtshirtgamingstudios2126
    @redtshirtgamingstudios2126 3 ปีที่แล้ว +7

    Brackeys: *Makes an if statement to prevent errors
    Unity's errors: You can't escape me that easily!

  • @donaldleow6119
    @donaldleow6119 5 ปีที่แล้ว +4

    Thank you very much for this video! I have struggled to make a melee combat work since forever and been stuck doing platform shooter games instead...this is a game changer for me!!!

    • @donaldleow6119
      @donaldleow6119 5 ปีที่แล้ว

      Just to add on, if there's a melee combo system that works with the method you used in this video, it would be great if you could post that as well!

    • @SidMakesGames
      @SidMakesGames 5 ปีที่แล้ว

      I know right bro, melee combat just add another flavor to the game. Not just melee combat for Player but it's great to have enemies which actually attack player.
      I am covering the Enemy Melee Combat system on my channel. You might love it too

  • @lyamschuss8786
    @lyamschuss8786 4 ปีที่แล้ว +201

    My Brain: See this!
    Me: But I'm not a game developer
    My Brain: Just in case...

    • @ПетърМихов-н9ю
      @ПетърМихов-н9ю 3 ปีที่แล้ว +17

      My brain: See this!
      Me: But I already created my own method of melee attacks and it works very well.
      My brain: Just in case

    • @stenty8464
      @stenty8464 3 ปีที่แล้ว +3

      funny thing that i don't understand almost everything in this video but i got the idea how it works

    • @viporal7898
      @viporal7898 3 ปีที่แล้ว +3

      @@stenty8464 way to go, smarty pant

    • @pumpkinpeen5937
      @pumpkinpeen5937 3 ปีที่แล้ว

      why stop at one pant

    • @AhmedMohamed-zj1qc
      @AhmedMohamed-zj1qc 3 ปีที่แล้ว

      @@ПетърМихов-н9ю what is it

  • @finnleyhauser5362
    @finnleyhauser5362 ปีที่แล้ว +6

    So for the floor in my game I used a tileset with a box 2D collider which means whenever the enemy dies it falls through the floor anyway to fix this also whenever I attack the enemy I can swing as fast as I want and other than that this is a great video and has been tons of help.

    • @senkerog
      @senkerog ปีที่แล้ว +4

      Also using a tileset and had the same issue, this line before disabling the collider will keep the enemy in place
      GetComponent().isKinematic = true;

    • @gewsbahks6224
      @gewsbahks6224 ปีที่แล้ว +1

      @@senkerog Thanks!

    • @burkanaydn9944
      @burkanaydn9944 ปีที่แล้ว

      use "animator = GetComponent();" in update

  • @fromagedecayenne1727
    @fromagedecayenne1727 5 ปีที่แล้ว +2

    By far the best melee combat system tutorial i ever watched.
    Your videos are productive and very entertaining,please continue.

  • @calcite_dragon
    @calcite_dragon 2 ปีที่แล้ว +4

    Great tutorial! Thanks!
    ...even though you're gone.

  • @PedroFerreiragm33
    @PedroFerreiragm33 5 ปีที่แล้ว +120

    Your tutorials are so easy to follow that I'm pretty sure a baby could make a successful game with your tutorials alone 😃

    • @aurorapaisley7453
      @aurorapaisley7453 5 ปีที่แล้ว +2

      😆

    • @taylorheninger5196
      @taylorheninger5196 5 ปีที่แล้ว +15

      Well I'm trying!!

    • @xXTheivesGuildXx
      @xXTheivesGuildXx 5 ปีที่แล้ว +5

      Ehh. Honestly a baby would need to also have a computer which is pretty unlikely. And I don’t think a baby would understand most of the computer terms so you’re kinda wrong..

    • @Mikeul2GT
      @Mikeul2GT 5 ปีที่แล้ว +18

      @@xXTheivesGuildXx /woooshh

    • @VI.mp4
      @VI.mp4 5 ปีที่แล้ว +6

      @KaiVideoSYT no it's r/woooosh

  • @goldenredstone04
    @goldenredstone04 5 ปีที่แล้ว +3

    I have been struggling with this all week and this explained exactly how to do it. Thank you!

  • @dhruvagrawal3856
    @dhruvagrawal3856 4 ปีที่แล้ว +1

    If you were not there I would not have been able to make combat system for my game and I tried a lot making that on my own but failed then I came to your video that I remembered that you made thanks you are a saver and a god of game development
    THANKS A LOT

  • @eziostone1109
    @eziostone1109 5 ปีที่แล้ว +3

    Geez Brackeys you make it look soo easy, I tried for *months* to do this with a little success in 3D and you make it in around a half hour :P
    Thanks man :D

    • @madpancake9891
      @madpancake9891 5 ปีที่แล้ว

      I figured how to do it alone after like a month of making ambitious yet impossible to complete games so it's not this hard. Maybe you're not really working on it just launching unity for 10 minutes a week.

    • @emailakkont6520
      @emailakkont6520 5 ปีที่แล้ว +2

      @@madpancake9891 You're such a special little snowflake :-)

    • @beri4138
      @beri4138 4 ปีที่แล้ว

      @@madpancake9891 Yeah? Well I got all the golden berries in Celeste. Get on my level.

    • @madpancake9891
      @madpancake9891 4 ปีที่แล้ว

      @@beri4138 I'll never beat you, but I'll try senpai

    • @madpancake9891
      @madpancake9891 4 ปีที่แล้ว

      @@emailakkont6520 yeah i was trying to make it sound funny, not smart-assy, kinda stupid as I've trashed Unity just after writing this comment.

  • @willlacey7621
    @willlacey7621 4 ปีที่แล้ว +2

    Recently found your channel, it has since really been helping me in Unity! Much thanks, Brackeys! :)

  • @andrinluthi9581
    @andrinluthi9581 4 ปีที่แล้ว +4

    My death-animation from the Enemy does not stop

    • @kingofcode1323
      @kingofcode1323 4 ปีที่แล้ว +5

      Disable looping in the animator...

  • @PhuocNguyen-xq2ub
    @PhuocNguyen-xq2ub ปีที่แล้ว

    I've just started to learn Unity and luckily seen these your videos, it's truly practical

  • @jamesalbus7991
    @jamesalbus7991 5 ปีที่แล้ว +13

    1:18 absolutely Quackers mate 😂

  • @parmesanzero7678
    @parmesanzero7678 ปีที่แล้ว

    This was a better tutorial and gave me a better understanding than much longer and more involved ones in how to use unity.

  • @yoelmarquez5029
    @yoelmarquez5029 4 ปีที่แล้ว +4

    I see Dani in all the game development videos I watch lmao

  • @alessandroiervo
    @alessandroiervo ปีที่แล้ว

    Best melee combat video i've seen, very simple and intuitive.

  • @throughdarkness
    @throughdarkness 4 ปีที่แล้ว +3

    Thank you so much for these videos, Brackeys! First time learner or unity and your information and presentation is easy for me to keep along with. really thanks a million!

  • @jozimastar95
    @jozimastar95 2 ปีที่แล้ว +1

    9:00 if anyone cant chose .position just make it gameopj instead of transform or use attackpos.transform.position

  • @celalozdemir8565
    @celalozdemir8565 3 ปีที่แล้ว +3

    18:21 'He gets hurt and he DIES...Awesome!"

  • @keithwilkes7069
    @keithwilkes7069 ปีที่แล้ว

    Ive been coding for two years... this is months of knowledge in a single video. Huh, wish i found this guy sooner.

  • @cinemacat4108
    @cinemacat4108 3 ปีที่แล้ว +3

    if you want to simulate the attack in physics you can make disable the collider of the melee and when you want the player to hit something in the animation add a key frame of enabling the collider and after that frame disable the collider this is a solution of many problems in the comment section :D
    But with this method you can't use brackey's health system you should use the OnCollisionEnter2D

  • @satobi46
    @satobi46 2 ปีที่แล้ว

    Blackthornprod and Brackeys have the best unity video tutorials!

  • @kseroxe
    @kseroxe 2 ปีที่แล้ว +3

    From my expirience there are many other ways to create a melee combat in your game. Personally I just create animation, which activates and deactivates trigger around the sword/spear e.t.c. at the right moment.

    • @timurradman3999
      @timurradman3999 2 ปีที่แล้ว

      You can't do that if it was a fighting game, different characters will have different triggers :) it's painful to set it in animations

  • @ODCrab
    @ODCrab 5 ปีที่แล้ว +1

    Made me feel better about my melee system. The script got a little more complicated when I tried to it compatible with all basic colliders and compound ones. The main difference is that my "hit point" tracks the weapon bone and it needs to be check every fixed update during the animation. I ended up combining it with a StateMachineBehaviour to confine the checks to the animation and cashing the collision log between checks to prevent redundant calls.
    I also made a pseudo "collision info" object to store some basic info that I use for effects and knock back. I was kind of worried that I was over complicating things. But I just couldn't figure out how to make something behave like a trigger but still get physics info I need with the built in system.
    I ended up learning a lot about StateMachineBehaviours. They are pretty cool and I never see anybody mention them.

  • @technotechmusic
    @technotechmusic 5 ปีที่แล้ว +3

    Your 2D series is very helpful, thank you. Please do more!

  • @kitsunedotexe3587
    @kitsunedotexe3587 4 ปีที่แล้ว

    took me so long to find a video to show how to make a health/damage system thats easy to understand, thank you!

  • @theonetruedonut
    @theonetruedonut 5 ปีที่แล้ว +42

    I would love to see a tutorial on tactics games (games like advanced wars or fire emblem)

    • @ZiRR0
      @ZiRR0 5 ปีที่แล้ว

      Nice profile pic!

    • @theonetruedonut
      @theonetruedonut 5 ปีที่แล้ว +1

      @@ZiRR0 thanks I drew it myself

    • @ZiRR0
      @ZiRR0 5 ปีที่แล้ว

      @@theonetruedonut Mind telling me what program you used?

    • @theonetruedonut
      @theonetruedonut 5 ปีที่แล้ว

      @@ZiRR0 Gravit Designer but I also recommend Inkscape

    • @ZiRR0
      @ZiRR0 5 ปีที่แล้ว

      @@theonetruedonut Thanks!

  • @hichambenriane6869
    @hichambenriane6869 ปีที่แล้ว +1

    Brackeys the master of unity

  • @someone-js6pg
    @someone-js6pg 5 ปีที่แล้ว +10

    Please do another beginner game series i'm not even a beginner and i want another one.
    it's just fun to do

  • @TheRealKaiProton
    @TheRealKaiProton 5 ปีที่แล้ว

    Fantastic, Ive had trouble understanding that Physics2D circle, command for a while, and you combined it with an array, and I still understood. Brilliant

    • @jantran5349
      @jantran5349 5 ปีที่แล้ว

      Well you can use. Debug.DrawRaycast thing to see where the hitbox is at.

  • @birgerevan
    @birgerevan 5 ปีที่แล้ว +39

    Pls, do a tutorial on the new ECS (DOTS), and the newmultiplayer packages

    • @aleef1735
      @aleef1735 5 ปีที่แล้ว +1

      I'd love to see a video on how to use the multiplayer system from the FPS Sample in a new project. I'd also pay for it.

    • @lethn2929
      @lethn2929 5 ปีที่แล้ว

      @@aleef1735 yes the new unity multiplayer stuff desperately needs looking at and some proper tutorials and documentation.

    • @corey6796
      @corey6796 5 ปีที่แล้ว

      Yes

    • @xXTheivesGuildXx
      @xXTheivesGuildXx 5 ปีที่แล้ว

      Birger E yes I need to figure out multiplayer for my game

    • @NANI-cp9mg
      @NANI-cp9mg 5 ปีที่แล้ว

      Yes, please do this!

  • @qhailashnikov
    @qhailashnikov 5 ปีที่แล้ว +1

    Brackeys is closing to 1M subs yay

  • @DrewofDonuts
    @DrewofDonuts 4 ปีที่แล้ว +9

    Make sure the Gizmos button in checked in the editor! I repeat, do not waste an hour trying to get OnDrawGizmosSelected to work because you didn't check the button and now you hate yourself because you ate half a cake to get through the stress!

    • @mralien9547
      @mralien9547 3 ปีที่แล้ว +1

      God bless you

    • @sureshchandrajain9614
      @sureshchandrajain9614 3 ปีที่แล้ว +2

      Can you please elaborate ? I am stuck on that exact step. My player combat script simply isn't accepting the acceptpoint. If i drag and drop, it appears for a sec, and then it is again set to None. Pretty sure my gizmos button is set to on though.

    • @kaijuuking
      @kaijuuking 3 ปีที่แล้ว

      Jfc man, I've just wasted an hour trying to figure it out, I wish I see your comment sooner

  • @andrewcgs
    @andrewcgs 4 ปีที่แล้ว +1

    1:10 DUCK TAPES! WHOO-OHH!

  • @quimtorra3981
    @quimtorra3981 5 ปีที่แล้ว +4

    Next one has to be "Melee Combat COMBOS in Unity", or something about attack sequence, because repeating the same animation over and over isn't really beautifull for the player. It would really help a lot
    Nice video btw

    • @deadrosas
      @deadrosas 5 ปีที่แล้ว

      Quim Torra just need a static variable and attack based on that

    • @nutsquirrel84
      @nutsquirrel84 5 ปีที่แล้ว

      Yeah i couldnt figured out combo system too. How can i check for second attack i couldnt find.

    • @beri4138
      @beri4138 4 ปีที่แล้ว

      Blasphemous and Hollow Knight disagree

  • @fecoramirez
    @fecoramirez 5 ปีที่แล้ว +2

    I was searching for a melee tutorial in all your channel last week because of an urgency. Still really helpful.

  • @michaelmietz1800
    @michaelmietz1800 3 ปีที่แล้ว +12

    Awesome video! This helped me a bunch!
    One question though:
    How do you make the attackpoint flip to the other side when you sprite fliX?

    • @InternationalConglomerate
      @InternationalConglomerate 3 ปีที่แล้ว +5

      Set the localPosition on the transform to a negative vector2

    • @GameAdonis
      @GameAdonis 3 ปีที่แล้ว

      @@InternationalConglomerate in script or in editor

    • @InternationalConglomerate
      @InternationalConglomerate 3 ปีที่แล้ว +1

      @@GameAdonis In script, you want to set it so that it will flip to the corresponding direction you are moving programmatically. Depending on how you do it you may need to put in some checks to make sure it isn't already on the correct side or it will flip back and forth constantly as you walk.

    • @evan73858
      @evan73858 3 ปีที่แล้ว

      @@InternationalConglomerate I had this same issue, and what I wrote was
      attackPoint.localPosition = new Vector2(-attackPoint.position.x, attackPoint.position.y);
      but when I play test it as soon as a i start to move the attack point vanishes. help? 😅

    • @InternationalConglomerate
      @InternationalConglomerate 3 ปีที่แล้ว

      @@evan73858 When it moves, double click the objects name in the hierarchy, should move your scene view to wherever it is. Likely it's a problem with the vector2 math. Could try changing attackPoint.position.x to attackPoint.localPosition.x as just from a glance I think that might be your problem.
      The position variable is going to be completely different from the localPosition variable so if you make it negative based off Position instead of localPosition it will be entirely different coords.

  • @reganlam9940
    @reganlam9940 9 วันที่ผ่านมา

    Love the way you code why commenting out what you want the code to eventually do.

  • @charKT-7461
    @charKT-7461 5 ปีที่แล้ว +6

    The anime character 1 second after seeing enemy: 0:21

    • @xtragamez7195
      @xtragamez7195 3 ปีที่แล้ว

      if its naruto then its -6 seconds before seeing them lol

  • @CalamityVirus
    @CalamityVirus 4 ปีที่แล้ว +1

    I love your videos. I found you when I first watched your "love is blind" game jam. I wish there was someone like you for Unreal as thats what I am being taught in college, but I enjoy your vids anyway

  • @Salmontres
    @Salmontres 4 ปีที่แล้ว +11

    any chance of getting a combo system tutorial? Doesn't need to be complex, but I'd love to see how you tackle things like stringing together attack combos, but allowing for a chance to drop the combo if the keys are pressed too fast or something

  • @Syr3
    @Syr3 ปีที่แล้ว

    Brackeys is simply the best. Most educational videos on the platform

  • @aisforanimate4703
    @aisforanimate4703 5 ปีที่แล้ว +4

    I feel like every video he's like "hmm, I wonder what weird thing I can do with my hair today?"

  • @n1nevite
    @n1nevite 3 ปีที่แล้ว

    That cut in the start is very smooth!

  • @gamedev.1166
    @gamedev.1166 5 ปีที่แล้ว +7

    It is really really simple and easy to learn. thanks~

    • @comet_195
      @comet_195 2 ปีที่แล้ว

      aiidiasdwass

  • @MrAronur
    @MrAronur ปีที่แล้ว

    Watching this now in 2023, and it´s great help. Much love from an asspiring game dev from Norway

  • @Exorion1er
    @Exorion1er 5 ปีที่แล้ว +243

    Most of the comments : "Next time show how to make a fully fledged game ready to be sold" *facepalm*

    • @SuperMinecraft567
      @SuperMinecraft567 5 ปีที่แล้ว +20

      Well technically did that already... Many times.

    • @elektra81516
      @elektra81516 4 ปีที่แล้ว +5

      @@SuperMinecraft567 not really store-ready though, mostly prototypes

    • @elektra81516
      @elektra81516 4 ปีที่แล้ว +18

      Something like "Can you make an MMO RPG Battle royale tutorial please?"

    • @jjj7790
      @jjj7790 4 ปีที่แล้ว +9

      @@elektra81516 The tutorial video for a store-ready game is just going to be "Work on your game for potentially years in a repetitive cycle of feature implementation, getting feedback, and bug-fixing, until you run out of time or money."

    • @beri4138
      @beri4138 4 ปีที่แล้ว +8

      CAN YOU MAKE A GAME LIKE BORDERLANDS 3 OR GTA 5 THANKS

  • @silversoulboy8706
    @silversoulboy8706 5 ปีที่แล้ว

    The advertisments on these videos are the best

  • @ChooseKindness9999
    @ChooseKindness9999 5 ปีที่แล้ว +3

    I’ve been sitting here like: “Blackthornprod has tutorials on this! Sykoo has tutorials on this! GMTK even talks about it! Come on Brackeys!”

  • @nel9954
    @nel9954 5 ปีที่แล้ว +1

    Exactly what I needed. For me it's probably your most useful video yet!

  • @OutrageGames
    @OutrageGames 5 ปีที่แล้ว +23

    Very cool tutorial! I also use a similar technique in my melee combo system in one of my tutorials!

  • @ThisIsE.R.C
    @ThisIsE.R.C 2 ปีที่แล้ว +2

    a tip on how to better the code is that, If you know how to use the IEnumerator method to make a pause before allowing the player to use the attack again.
    hope its not too confusing

    • @scottwarner9856
      @scottwarner9856 ปีที่แล้ว

      That or create an isAttacking bool, and add it to the if condition:
      if (!isAttacking && Input.GetKeyDown(Keycode.Space))
      {
      isAttacking = true;
      Attack();
      }
      Then just add:
      "isAttacking = false;" to the end of the Attack() function, and you're set.
      This will make it so you cannot interrupt an attack animation with another attack animation, and eliminate the need to fine-tune a timer to your animation.

  • @FlutterBros
    @FlutterBros 5 ปีที่แล้ว +4

    Love your content. I wish I could teach Unity like you. I try my best :)

  • @boulderplayz6712
    @boulderplayz6712 5 ปีที่แล้ว

    Man I love the way you work so hard on your videos, but put minimal ads!

  • @albertvoiturier2483
    @albertvoiturier2483 2 ปีที่แล้ว +4

    I have an issue: the enemy keep playing death animation in loop even if I put ExitTime to 1 in the animator... Can someone help me please ?

    • @HomikiGaming
      @HomikiGaming 2 ปีที่แล้ว

      I’ve hope someone will help because I have the same problem :(

    • @sogyshorts5662
      @sogyshorts5662 10 หลายเดือนก่อน

      just disable loop

  • @FrostshadowStudios0310
    @FrostshadowStudios0310 4 ปีที่แล้ว +1

    This works great for my heavy action games. Thanks, man. I'm busy on a game that looks like Super Smash Brothers, just in a 3D environment, not 2.5D.

  • @filipe_paixao
    @filipe_paixao 4 ปีที่แล้ว +4

    just create a variable that can influence the attack rate, and that variable is influenced by the number of enemies killed.
    Then u get faster the more you kill.
    evolution is always the best thing in games.

  • @FIREHIVE
    @FIREHIVE 5 ปีที่แล้ว

    I can't belive it, I was just searching for a mele combat for my 2d game to implement it. And you posted this video, just on point.

  • @jeykey7140
    @jeykey7140 3 ปีที่แล้ว +6

    Had premade enemies (watched another tutorial by other creator) and my hits were not connection, in other words I was calling "attack()" method, but nothing was detected. Turns out you need a box collider 2D to make it work. Overall really good tutorial.

    • @PawzyPuppy
      @PawzyPuppy ปีที่แล้ว

      Been trying to get this to work for the better part of an hour. Thank you very much

  • @Mrityunjay7
    @Mrityunjay7 3 ปีที่แล้ว

    I just want you to know that your videos have really helped me a lot
    Seriously

  • @landphin5067
    @landphin5067 4 ปีที่แล้ว +6

    I find it odd that he never brought up that this only works facing one way. The attack point doesn't move when facing the other direction...

    • @infernojoe
      @infernojoe 4 ปีที่แล้ว +1

      it can actually work both ways!
      in Brackeys' 2D shooter tutorial, he mentions something about rotating the player. if the attackPoint is childed to the player, it rotates with the player!
      here's the 2D shooter tutorial:
      th-cam.com/video/wkKsl1Mfp5M/w-d-xo.html

    • @anirudhganesh7714
      @anirudhganesh7714 4 ปีที่แล้ว

      @@infernojoe you mean childed?

    • @infernojoe
      @infernojoe 4 ปีที่แล้ว

      @@anirudhganesh7714 yes

    • @anirudhganesh7714
      @anirudhganesh7714 4 ปีที่แล้ว

      @@infernojoe well it does rotate but the tricky thing is it cannot track the sprite movement nor can you record animation for that I think. Haven't tried recording and moving the circle.

    • @meljerichoasakki2046
      @meljerichoasakki2046 3 ปีที่แล้ว

      I found a way: use a blender tree in the animator, having a horizontal parameter already set, then use the left attack animations and the right ones as motions in this order. Disable the automate thresholds. If you want your default attack to be to the right, set the threshold right attack to 0.9

  • @alejandrosanchezsalcedo7076
    @alejandrosanchezsalcedo7076 3 ปีที่แล้ว +1

    Thank you for the Alt+arrow keys shortcut!!!

  • @Victor-kt6qn
    @Victor-kt6qn 4 ปีที่แล้ว +11

    Hope someone answers.
    Why is my enemy falling through the tiles when he dies?
    It plays the death animation but he just falls through.

    • @vigneshkrishnan5680
      @vigneshkrishnan5680 4 ปีที่แล้ว

      By any chance, is your collider set to be a trigger? In that case, the collision physics won't work

    • @thearonayne5731
      @thearonayne5731 4 ปีที่แล้ว

      Same problem here, did you find a solution?

    • @thearonayne5731
      @thearonayne5731 4 ปีที่แล้ว +16

      GetComponent().simulated = false;
      i ended up adding this to the void Die() method to disable gravity on the dead enemy model

    • @DarkGrisnak
      @DarkGrisnak 4 ปีที่แล้ว

      That's because you disable the collider when it dies. So if it is affected by some kind of gravity, it will fall through everything.
      I think a good way to avoid it would be to not disable the collider but instead change its layer and play with the layer matrix so the player won't interact with dead bodies. Putting it to background or whatever.
      I thought about it watching the video, hope it helps

    • @LURTZcz
      @LURTZcz 4 ปีที่แล้ว

      did you disable the script as in tutorial? You just need to disable correct component responsible for gravity.

  • @DZ_97
    @DZ_97 9 หลายเดือนก่อน

    i love Brackeys hes always got everything i need

  • @whyisthismyrealname
    @whyisthismyrealname 4 ปีที่แล้ว +3

    Quick question, would it not be better to determine your attack time with the animation length and/or speed?

    • @Ed-fs3xq
      @Ed-fs3xq 3 ปีที่แล้ว

      It would be better

  • @emerymarks7139
    @emerymarks7139 3 ปีที่แล้ว

    I like how I watched this video despite 1. I'm not designing a video game. and 2. I don't have plans on designing a video game. But it really intrigued me, after going through a web development class, how similar the coding is.

  • @skyacaniadev2229
    @skyacaniadev2229 5 ปีที่แล้ว +10

    Is it OK to attach collider to the weapon directly? I'm in 3D.

    • @TheStriked
      @TheStriked 5 ปีที่แล้ว +1

      I'm no developer, but I do think you need to ,so in order for the condition you gave to activate like in brackeys case display enemy hit

    • @haaly7245
      @haaly7245 5 ปีที่แล้ว +1

      Depends on the kind of combat system you want to make. Some games can be forgiving and say that an attack "hit" if a valid target is within a specific area. Others can be more punishing and check for actual collisions between the edge of the weapon and the target and the speed difference at the moment of the collision.

    • @SidMakesGames
      @SidMakesGames 5 ปีที่แล้ว +2

      In general it is okay to attach collider to the weapon directly, no matter if you are in 3D or 2D. But it is not the best method to approach it.
      I always suggest to have hitbox on a separate child object as it gives you more flexibility and control over your hitbox. And you can easily make changes to it without messing the sprite or textures

    • @haaly7245
      @haaly7245 5 ปีที่แล้ว +4

      @@SidMakesGames that is the actual way they do it in SSBU.
      Edit: also you want to use primitives for your hitboxes because they're highly optimized.

    • @SidMakesGames
      @SidMakesGames 5 ปีที่แล้ว +1

      @@haaly7245 I know right, that is the best method to approach it
      Also on primitives point, definitely, it is generally best to use primitives specially when you are creating a game like Street Fighter or SSBU where even mini-seconds matter

  • @chiarab7574
    @chiarab7574 ปีที่แล้ว

    this is the best tutorial ive seen out there

  • @brockormond4131
    @brockormond4131 5 ปีที่แล้ว +9

    Next show us how to make a 2D street fighter type character plz. Button combos and hit boxes etc

  • @jk3rrr
    @jk3rrr 3 ปีที่แล้ว +1

    "You attack him 3rd time, he dies. Awesome!

  • @SciFi.Horror.Thriller.Fantasy
    @SciFi.Horror.Thriller.Fantasy 4 ปีที่แล้ว +3

    How do you prevent reducing enemy health more often then once, in case the collison is true for more than one frame, I wonder? By the way ... you are a gifted teacher, great tutorials!

    • @sheanstanks
      @sheanstanks 2 ปีที่แล้ว

      I know this is an old post, but did you ever find a solution for this? I am using skeleton animation and I get like 10 collisions on the same object hahah. Still looking for a solution.

    • @archivedandgone
      @archivedandgone 2 ปีที่แล้ว +2

      @@sheanstanks you can always do what he did in the last two minutes of the video to limit the attack rate, but do it to the enemy scripts take damage function. Just have the program skip over it if only a few milliseconds have passed

    • @sSpectralls
      @sSpectralls 2 ปีที่แล้ว

      Did you find a solution?

    • @SciFi.Horror.Thriller.Fantasy
      @SciFi.Horror.Thriller.Fantasy 2 ปีที่แล้ว

      @@sSpectralls Add in Collision Event: Limit Conditions -> Only One Action When Event Loops

    • @SciFi.Horror.Thriller.Fantasy
      @SciFi.Horror.Thriller.Fantasy 2 ปีที่แล้ว

      EDIT: Forget it - What I wrote refered to MultimediaFusion 2. Sorry!

  • @999-y8k
    @999-y8k 5 ปีที่แล้ว +34

    Who’s Mee Lee?

    • @MehmetB.123
      @MehmetB.123 หลายเดือนก่อน

      Mee Lee Sin

    • @Johnnys_Manager
      @Johnnys_Manager หลายเดือนก่อน

      chinese person

    • @joedwyer3297
      @joedwyer3297 7 วันที่ผ่านมา

      My maths teacher

  • @timq16
    @timq16 3 ปีที่แล้ว

    This helped me a lot! Thanks so much. You won’t be forgotten

  • @andrejvicanovic3551
    @andrejvicanovic3551 5 ปีที่แล้ว +7

    I like your "Whooo" 😀 and can you do a tutorial about 2D dashing, it would be nice!

    • @danivalentine1280
      @danivalentine1280 5 ปีที่แล้ว +5

      Assuming you're using rb.velocity for movement. I would think you would just do something like if(Input.GetKey(KeyCode.LeftShift))
      {
      rb.velocity = force + sprintBoost;
      }
      If this isn't even close to what you wanted, I apologize haha

    • @danivalentine1280
      @danivalentine1280 5 ปีที่แล้ว +2

      force represents your current movement speed by the way. So however you set up your controller. And don't forget to multiply by Time.deltaTime

    • @andrejvicanovic3551
      @andrejvicanovic3551 5 ปีที่แล้ว

      @@danivalentine1280 thank you for answer but i tried everything from rb.velocity to changing transform.position i just dont get it. I mean i will try, but thatnks!

    • @danteyema4500
      @danteyema4500 5 ปีที่แล้ว +2

      Great idea👌

    • @danivalentine1280
      @danivalentine1280 5 ปีที่แล้ว

      @@andrejvicanovic3551 What you're looking for is a way to have a 2D character be able to move around, but then if you hold down a key to sprint? Maybe I'll make a tutorial for you if I get the time today.

  • @o_2731
    @o_2731 3 ปีที่แล้ว +2

    I learned so much from just watching your vids! Thank you for the great content

  • @georgelucas7029
    @georgelucas7029 4 ปีที่แล้ว +4

    Thank you for the video Brackeys! I have only one issue though. The error "object reference not set to in an instance of an object" appears each time the attack button is pressed, inside the loop code: foreach (Collider2D enemy in hitEnemies) {enemy.GetComponent().TakeDamage(attackDamage);} Any suggestions to solve it?

    • @bonnyxavier7661
      @bonnyxavier7661 4 ปีที่แล้ว

      i'm getting this same problem, did u fix it?

    • @tiagoroquito8660
      @tiagoroquito8660 4 ปีที่แล้ว +3

      @@bonnyxavier7661 I had the same problem and it was because my "Enemy" script was actually named something else. I fixed it by changing what was inside the to what my "enemy" script name was

    • @mainchar_tv
      @mainchar_tv 2 ปีที่แล้ว +2

      I know this is old but pretty sure there are people watching these vids even today. So, the comment above mine should fix the problem IF that is the problem you are facing but if not this might be it, for those who choose to group their enemies in a parent object and attach the script on it will also face the same issue. Attach your script to each enemy independently, hope that helps.

    • @federicofini7542
      @federicofini7542 2 ปีที่แล้ว

      @@mainchar_tv I'm actually having the same issue: "object reference not set to in an instance of an object"
      I checked the scripts name and they are fine, and I don't have enemies grouped to a parent object. I'm literally banging my head against the wall...

  • @wavyrenac
    @wavyrenac 4 ปีที่แล้ว

    Amazing vid rly gave me insparation to not give up and start with Unity again

  • @iZahvi
    @iZahvi 5 ปีที่แล้ว +3

    Awesome tutorial, this exactly what I was looking for and works like a charm. However since disabling enemy collider on death the enemy just falls through the ground. How do I get him to not fall through the ground and just lay on top of it like you have displayed in you video?

    • @iZahvi
      @iZahvi 5 ปีที่แล้ว +1

      I figured something out, not sure if it's the best way to do it but I set the gravity on the enemy Rigidbody2D to 0 I'm hoping this wont effect anything when I go to create a patrol path for the enemy AI.

    • @DayOfCasual
      @DayOfCasual 5 ปีที่แล้ว

      @@iZahvi it will make enemies killed in "air" not fall down.

    • @iZahvi
      @iZahvi 5 ปีที่แล้ว +1

      @@DayOfCasual This is not too big of a deal for me as none of my enemies move along the vertical axis so they don't get caught in mid air except for my ghost but I have a death animation for him that he just shrinks until he disappears, though I may add other enemies later like bats that would not shrink before disappearing. Is there a better way to achieve having the enemy not fall through the floor on death before being destroyed?

    • @thenacho6354
      @thenacho6354 3 ปีที่แล้ว

      @@DayOfCasual any other way to fix the problem?

    • @castlewhale4746
      @castlewhale4746 3 ปีที่แล้ว +1

      @@thenacho6354 This is a little late but if you specify what type of collider your attack will hit IE specifically box colliders, then you can give the enemy one box collider and one collider of another type and only disable the box collider when he dies, that way he doesn't fall through the floor once you disable his box collider. Not sure if it's the most elegant solution but it seems to work for me.

  • @royaleminiatures7150
    @royaleminiatures7150 2 ปีที่แล้ว

    This is so helpful. Thank you so much for including so much detail.

  • @RanonBentoPereira
    @RanonBentoPereira 3 ปีที่แล้ว +3

    Could someone help me? :D When i press the attack while walking, the animation freezes and don't back to normal. Seems like a conflit between 2 keys pressed at same time. How do i solve it?Like, presse attack while walking and after release attack key, keep walking? Thank you!

  • @nigel_blxck
    @nigel_blxck 5 ปีที่แล้ว

    I love these videos!!! Have an awesome Christmas and New Year Brackeys guys!

  • @florian9820
    @florian9820 4 ปีที่แล้ว +5

    Great tutorial but when my Enemy dies and the Collider gets enabled the enemy just drops through the ground

    • @harvey6257
      @harvey6257 4 ปีที่แล้ว +1

      if hes walking on ground and doesn't have any air time put the gravity scale to 0 on the rigidbody

    • @DeadPieYT
      @DeadPieYT 4 ปีที่แล้ว +1

      Maybe have it change the layer of the enemy to one that the player can't interact with?

    • @florian9820
      @florian9820 4 ปีที่แล้ว +1

      @@DeadPieYT Thanks a lot for commenting. It fixed the problem. Have a great day :)

    • @DeadPieYT
      @DeadPieYT 4 ปีที่แล้ว

      @@florian9820 Glad to help :)

    • @poloibarguen
      @poloibarguen 4 ปีที่แล้ว

      @@florian9820 How? :O