Melee Combat & Weapon System - Unity Beginner Tutorial

Поділитися
Вставка
  • Опубліковано 28 вер 2024
  • Use Code: ZYGERNY22 for an extra 10% off at checkout
    prf.hn/l/K9D1xV8
    Assets Used In The Video:
    on.unity.com/3...
    on.unity.com/3...
    In this beginner easy tutorial I will show you how to make a melee system for your game. This tutorial will cover how to create the mechanics of the weapon, animations and how to make it work in actual combat. I will go over how to deal damage with the weapon to enemies and how to set those enemies up. This is a more in depth tutorial as I wanted to give you the foundations of your melee system that you can use in your own game.
    At the end you will have an awesome universal melee system. That can be changed and easily implemented into your project.
    Discord: / discord
    Instagram: / gabzxd
    Twitch: / officialzyger
    Twitter: / zygerdesigns
    ➤WISHLIST MY GAME: store.steampow...
    Video Sponsored By Unity

КОМЕНТАРІ • 181

  • @unity
    @unity 2 роки тому +265

    Amazing content Zyger, really comphrehensive and clear. We love to see it ❤!

  • @xenvo274
    @xenvo274 Рік тому +6

    OH MY GOD I WANTED TO DELETE MY WHOLE GAME BC I COULDNT GET THE ANIMATIONS TO WORK
    I HAVE BEEN LOOKING FOR A SOLUTION FOR TWO WEEKS
    YOU'RE THE BEST

  • @cfundeniable3442
    @cfundeniable3442 Рік тому +2

    I’ve been a fitness coach for 15 years. I know nothing about game development, and I’m starting to learn. Although I’m new to game dev, I am quite experienced at teaching. You are very good teacher! Subscribed!

    • @Ytsssss364
      @Ytsssss364 Рік тому +1

      overall, good AttackCoolDwon... ok well - but the wp vs. wc oversight *egads* - beginner's are having enough trouble as it is - also, showing making the "Attack" trigger in the Animator Controller instead of having it prepopulated like was done later for "Hit" trigger demonstration - would have been better teaching practice. But hey. Only a teacher like me would maybe nitpick on things like this

  • @mattiusstrutton
    @mattiusstrutton 2 роки тому +11

    This was a great tutorial! For anyone confused with coroutines I encourage you to look into it. But, if you still can't wrap your head around it just yet don't get frustrated. You can also use the animator to turn on and off the weapons collider as a hack-y solution. Thank you, Zyger for making the video. I never would have thought of making the weapon hit box bigger to hit the enemies and would have spent a lot of time wondering why it wasn't working haha.

    • @TheJuggernaut.
      @TheJuggernaut. 2 роки тому

      Every time I press the attack button, it does not work, what do I do? Is there a way to change the attack button to the space button?

  • @W0B0N
    @W0B0N 2 роки тому +7

    I have never done any coding but i feel like i learned something from this. Great video.

    • @ahmadgamal65
      @ahmadgamal65 2 роки тому +2

      You are missing out bro you never wrote any code??

    • @Cat_6921
      @Cat_6921 Рік тому

      omg

  • @ArtisticallyGinger
    @ArtisticallyGinger 2 роки тому +3

    I see you started looking into Coroutines to make your life easier.
    They make your processes waaaaay easier :D

  • @jackslammer
    @jackslammer Рік тому +1

    Will be using the lessons here to integrate into my own game, thank you so much for posting this.

  • @baulbasauur7659
    @baulbasauur7659 9 місяців тому +1

    exactly what i was looking for

  • @mismatchingshoes5249
    @mismatchingshoes5249 2 роки тому +1

    You know you’ve peeked when unity sponsors you

  • @kimikazio
    @kimikazio 2 роки тому +2

    fantastic, it helped me a lot to understand animation in unity. Thanks for making this video! ;)

  • @thesilentwisp
    @thesilentwisp 2 роки тому +2

    Thank you so much I'm just starting out and this is super helpful.

  • @purjolokgaming8482
    @purjolokgaming8482 Рік тому +2

    I have a slight problem, when my weapons box collider already collides with the enemys before i attack, nothing happens when i acctually do attack. I might have done something wrong. It works normally when the weapon box collied does not collide with the enemy before.

  • @ChildishSoap
    @ChildishSoap 2 роки тому +1

    Thank U Soo Much I needed this for my first Game the only part im stuck in is in the animations ahah

  • @schmutzxD
    @schmutzxD 2 роки тому +9

    Really well explained, thanks for that! I tried using your method with a third person controller, and I actually got it done working quite well. I'm struggling to get a decent attack combo system done though. I tried to make a transition between the first hit animation and the first combo hit animation just like you did with the first one, using the previous attack trigger as a trigger for the second transition, but I can't seem to get it done. You would have to click LMB in just the right moment to get the transition done and sometimes for some reason the animation gets stuck and won't transition to an other animation for a very short moment(

    • @dot5527
      @dot5527 2 роки тому

      i have the exact same issue

  • @vrutantshah8266
    @vrutantshah8266 Рік тому

    Thank you soo much! Finally got the animations working!

  • @rothhomemade
    @rothhomemade 6 місяців тому

    I will give you credit on my game's demo! thnk sooo much

  • @LukaRBJJ
    @LukaRBJJ 2 роки тому +1

    Awesome video, neatly explained!

  • @VkStudio_
    @VkStudio_ Рік тому +1

    Hey great video but i wanted to make it so that when i attack that the camera shakes a little idk how to do that i could really use your help.

    • @ZygerGFX
      @ZygerGFX  Рік тому +1

      just make a camera shake script and call the shake function when you press your attack button. Brackeys has a great video on camera shake: ua-cam.com/video/9A9yj8KnM8c/v-deo.html

  • @roscoeroly
    @roscoeroly 2 місяці тому

    Awesome video Gabi. "Cooldwon" caused my OCD to flare up and I almost got an aneurism, but apart from that 10/10.

  • @farasapt6579
    @farasapt6579 Рік тому +1

    great tutorial. but at the end the coding doesn't work for me as the last minute. So at 19:01, when I type wc.IsAttacking)
    , an error called ' Assets\Scripts\CollisionDetection.cs(12,39): error CS1061: 'WeaponController' does not contain a definition for 'IsAttacking' and no accessible extension method 'IsAttacking' accepting a first argument of type 'WeaponController' could be found (are you missing a using directive or an assembly reference?)
    great tutorial but I hate coding :(

    • @ZygerGFX
      @ZygerGFX  Рік тому

      do you have a variable under the name "IsAttacking" ? is that how its spelt ? is it accessible ? That error basically says that this variable is either not accessible or doesn't exists ( which is usually due to spelling or the protection level of the variable)

  • @CatsandPolygons
    @CatsandPolygons 2 роки тому +1

    Thanks a lot this really helped me!

  • @malcolmgruber8165
    @malcolmgruber8165 2 роки тому +2

    This is a great tutorial, but I was laughing for part of it because the players capsule looks like a turd. xD

  • @sleepyaj
    @sleepyaj 2 роки тому +2

    Hi uhm im hoping you'll respond to this, the tutorial is really helpful so far but one tiny problem that i've been stuck on is,
    when i'm preparing to use the animator. No matter how many times I drag the animation into the animator- nothing seems to pop up?
    Did I do something wrong?
    I've tried clicking to select the Sword-Attack/Sword-Idle then dragging it, dragging it without selecting it and nothing.

    • @ZygerGFX
      @ZygerGFX  2 роки тому

      This is actually a unity bug and had been for a while. I reccomend resetting unity and reopening the project. Worst case scenario you might need to re install it. But before that make sure yoy actually have the object with the animator component selected.

    • @sleepyaj
      @sleepyaj 2 роки тому

      @@ZygerGFX Thank you so much! I did what you said and made an entirely new project and repeated the same steps in the video and it works! Thank you so much for responding! ;D

  • @benjismith2848
    @benjismith2848 7 місяців тому

    Love the tutorial! Not sure if anyone else has run into this problem too but the Hit animation where the enemy gets knocked back after being hit, sometimes plays twice? tried a few different things but can't figure out whats causing it? I basically done the scripts just as the ones in this video.

  • @dcry1003
    @dcry1003 2 роки тому +2

    hey zyger question, can i use this code combined with the code for pick up and throwing gameobjects (melee weapons)?
    *i dont really have a code for a pick up and throw gameObjects i just had a thought for picking up weapons and being able to use them (like you did here) and also being able to throw them for long range dmg option*

  • @deni5368
    @deni5368 9 місяців тому

    it stays in the position that i finished the animation so when i click to attack it reverses from left to right. I made the animation go from right to left. can somone pls help?

  • @rogersun6184
    @rogersun6184 Рік тому +1

    Thank you very much :)

  • @lucaslessa318
    @lucaslessa318 Рік тому

    Thank you very much! You are a hero!

  • @scubaking4690
    @scubaking4690 2 роки тому +2

    Nice video it really helped me out, but I have a question. I tried making a second attack, made a trigger for it, and just copied and pasted your code, but changed the trigger name and the input button, swordattack, and canattack. After I did it, everything seemed to work, but when I pressed the button for the second attack, it worked, but kept repeating with no way to turn it off. Could you please tell me what I messed up?

    • @ZygerGFX
      @ZygerGFX  2 роки тому

      kind of hard to tell but make sure your animation is not on loop. if you find the animation you can see if its turned to loop or not!

    • @scubaking4690
      @scubaking4690 2 роки тому

      Sorry how do I do that?

    • @ZygerGFX
      @ZygerGFX  2 роки тому +3

      @@scubaking4690 well in the video I make an animation and I turn of loop. but you can go on the animation and turn it off

    • @scubaking4690
      @scubaking4690 2 роки тому +2

      @@ZygerGFX Thank you so much it finally fixed itself. for some reason after I do the animation I have to click the button again to do other animations but that's fine. Thanks again so much!

  • @aimanrazia3236
    @aimanrazia3236 3 місяці тому

    Can we apply this same to third person view

  • @Ytsssss364
    @Ytsssss364 Рік тому

    @17:13 you use "wp" for the "WeaponController" - I miss the part where you change it at random to "wc" - what gives??? like at 18:47, it's "wc" - did you make this tutorial while sitting in the WC?

  • @NotDoubleA
    @NotDoubleA 2 роки тому +1

    This was such a good tutorial and i really thought i was able to pull it off, lol nope got error CS1061. i'll still like the video though.

    • @ZygerGFX
      @ZygerGFX  2 роки тому

      what is the error ?

    • @NotDoubleA
      @NotDoubleA 2 роки тому

      @@ZygerGFX This is the error code i got. "Assets\WeaponContoller.cs(26,31): error CS1061: 'GameObject' does not contain a definition for 'GetComponet' and no accessible extension method 'GetComponet' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)

    • @ZygerGFX
      @ZygerGFX  2 роки тому +1

      @@NotDoubleA you spelt it wrong .. its meant to be GetComponent not GetComponet

    • @NotDoubleA
      @NotDoubleA 2 роки тому

      @@ZygerGFX oof, i didn't even notice it. thanks for that quick reply

  • @JaketheMotorhead
    @JaketheMotorhead 2 роки тому +1

    I keep getting this error: InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
    Weapon_controller.Update () (at Assets/Weapon_controller.cs:13) Can you help?

    • @ZygerGFX
      @ZygerGFX  2 роки тому

      you are using the new input system. so you need to either change to the old one. or change the way your checking for input.

    • @JaketheMotorhead
      @JaketheMotorhead 2 роки тому +1

      @@ZygerGFX How do you change the way. I tried changing to the old one and there were compile errors in the movement.

    • @JaketheMotorhead
      @JaketheMotorhead 2 роки тому

      @@ZygerGFX how do you change the way your checking for input?

  • @captaingames2037
    @captaingames2037 7 місяців тому

    really helpful

  • @GMRV533
    @GMRV533 Рік тому

    at 5:25 i did the same things as u did but my sword just keeps swinging

    • @ZygerGFX
      @ZygerGFX  Рік тому

      is your animation set to loop ? if so disable that checkbox

  • @SenpaiMasterGD
    @SenpaiMasterGD Рік тому

    i cant get the ¨hit ¨ to show do you know why @Zyger

  • @234zuscoutjango9
    @234zuscoutjango9 2 роки тому

    if i put Debug.log(other.name) in the part whereit is checked with with tag the sword collides i only get the name of my first person controller and i have no idea why

  • @fox.9879
    @fox.9879 2 роки тому

    i have these three issues can anyone help with this
    error CS0119: 'Component.GetComponent()' is a method, which is not valid in the given context
    Assets\collisionDetection.cs(13,31): error CS0103: The name 'wc' does not exist in the current context
    Assets\WeaaponController.cs(34,18): error CS0428: Cannot convert method group 'GetComponent' to non-delegate type 'AudioSource'. Did you intend to invoke the method?

  • @fogcomign
    @fogcomign Рік тому

    Thank you!

  • @DayDreamSounds
    @DayDreamSounds Рік тому

    very late here. When I attack the first time, canAttack doesn't become true again. It just stays unticked. I double checked code but can't find anything :(

    • @DayDreamSounds
      @DayDreamSounds Рік тому

      Nevermind. Obviously didn't check code properly. I didn't even start the coroutine haha!

  • @blackespectral
    @blackespectral Рік тому

    thank you so much

  • @alsowow
    @alsowow Рік тому

    I have a problem, i have an enemy that can move and look around, but hen i give it animations it can't move or look around. any tips to prevent this?

    • @ZygerGFX
      @ZygerGFX  Рік тому

      make sure your animations don't alter the position of the object. That will prevent it from moving. So just remove the position changes in the animation :)

  • @Astrobot-fan
    @Astrobot-fan 7 місяців тому

    its hard zyger i cant do it

  • @Skeltcher
    @Skeltcher 2 роки тому

    Im getting this error after finishing the WeaponController script.
    "InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings."

    • @ZygerGFX
      @ZygerGFX  2 роки тому

      your trying to detect input using the old input system methods while your using the new one. Either change the way your checking for input or revert back to the old input system.

  • @DetectiveRyku
    @DetectiveRyku 2 роки тому

    Thank you

  • @kingofroms7224
    @kingofroms7224 2 роки тому

    thansk for it

  • @DwuhTypufGranie
    @DwuhTypufGranie 2 роки тому +1

    11:17

  • @sdvilhidfhvs
    @sdvilhidfhvs 2 роки тому

    what abt the fps game??
    is it canceled?

  • @majesticchicken3213
    @majesticchicken3213 Рік тому

    this is really2 good

  • @dezhofman3958
    @dezhofman3958 Рік тому

    Does anyone know why my mouse button isn’t working i set it to input.Getmousebutton(0) but it isn’t doing anything in my game

    • @ZygerGFX
      @ZygerGFX  Рік тому

      Make sure to use the old input system. And ensure there are no errors. It should be Input.GetMouseButtonDown(0)

    • @dezhofman3958
      @dezhofman3958 Рік тому

      @@ZygerGFX yeah i forgot to type down in my comment 😅 but what do yeah mean by making sure to use the old input system

    • @ZygerGFX
      @ZygerGFX  Рік тому

      @@dezhofman3958 well unity has 2 systems the old classic one and the new one so just double check which one your using I project settings. Also debug your code see if the function gets called and if the input is actually detected.

  • @supernick7773
    @supernick7773 2 роки тому

    Hi, i recently started coding in unity and I have copied everything from the video, until 10:26, but when I press the button, nothing happens. Do you have any fixes?

    • @ZygerGFX
      @ZygerGFX  2 роки тому

      Debug your code. Chekc whether functions get called. Whether the input actually gets called and is working. From what you said I cant tell what's wrong but just debug your code and check if things get called

    • @supernick7773
      @supernick7773 2 роки тому

      @@ZygerGFX how do I debug the code

    • @ZygerGFX
      @ZygerGFX  2 роки тому

      @@supernick7773 I recommend researching how to do that. but you should use debug.log to send messages. you can write this in functions and you will receive a message in the console. which will tell you that the function gets called. if you don't see it, then it means it doesn't get called. which means something is causing the function not being called. you can always join the discord server and ask people in the help channel for help ! :))

  • @GameBoy-ur9mb
    @GameBoy-ur9mb 2 роки тому +2

    SECOND BRACKEYS PLAS!

  • @kokorodev1219
    @kokorodev1219 2 роки тому

    i need 3rd person

  • @prrithwirajbarman8389
    @prrithwirajbarman8389 2 роки тому

    Found ya

  • @bisutowastaken
    @bisutowastaken 2 роки тому

    14:00

  • @monkeefox5997
    @monkeefox5997 2 роки тому

    cool

  • @bisutowastaken
    @bisutowastaken 2 роки тому

    6:13

  • @Al3bassy
    @Al3bassy 2 роки тому +1

    wowo 10 seconds ago

  • @alphakelo
    @alphakelo 2 роки тому

    How could I use this to kill an enemy?

    • @ZygerGFX
      @ZygerGFX  2 роки тому

      well in the video I showed how enemies can detect an attack from the player. in my case I make them play an animation and spawn some particles. but if you want to deal damage do that there. and what you do will depend what sort of health system you have implemented.

    • @alphakelo
      @alphakelo 2 роки тому

      @@ZygerGFX Ok, Thank You.

    • @alphakelo
      @alphakelo 2 роки тому

      @@ZygerGFX Sorry, one last question what particle did you use?

    • @ZygerGFX
      @ZygerGFX  2 роки тому

      @@alphakelo dont apologise xD. what do you mean by what particle ? its one I made myself

    • @alphakelo
      @alphakelo 2 роки тому

      @@ZygerGFX ohhh ok, (I'm new too unity and Coding thought that particles were a prebuilt thing lol)

  • @MugiwaraLevi560
    @MugiwaraLevi560 2 роки тому +2

    im the first like lets go

    • @MiloTheDuck-s7j
      @MiloTheDuck-s7j 2 роки тому

      No you're 2nd

    • @startandplay6706
      @startandplay6706 2 роки тому

      hey friend can you make this video in a new way for 2021...,
      ua-cam.com/video/ajzHkYow-so/v-deo.html&ab_channel=DonHaulGameDev-Wabble-UnityTutorials

  • @QuadDamage3
    @QuadDamage3 2 роки тому

    Nice tutorial, but are you **in hurry** to somewhere? Clicking so quickly through scripts felt nearly criminal.

  • @SaikyoEdits_
    @SaikyoEdits_ Рік тому

    "As you can see this is extremely basic..."
    self esteem: 📉📉📉📉📉📉

  • @Driesipops
    @Driesipops Рік тому +3

    I spent the better part of 9 hours trying to figure out why the animation part wasn't working... editing code, placing debugs, looking for boolean code that would work, trying to put the script onto different assets to see if that would work... only to realize that I had accidentally made a bool instead of a trigger.
    Don't be a fool, don't be like good ol' Dries over here, make sure to check that your triggers are actually triggers before wasting 9 hours of your life.

    • @ZygerGFX
      @ZygerGFX  Рік тому

      Ah that sucks. I'm pretty sure I've done that before too... 😅 at least now you know

    • @fragdummy
      @fragdummy Рік тому

      you just saved me

  • @DaRealViso
    @DaRealViso Рік тому +8

    For people who have the problem of it not always registering the hit, the problem is that the collider is always active so therefor is always touching the enemy. To fix this first make a public gameobject for your hitbox and then have a HitBox.SetActive(true); for when you attack and a HitBox.SetActive(false); on your reset cooldown

    • @Garb0_
      @Garb0_ Рік тому +1

      How, pls help

    • @trentonbeeson7132
      @trentonbeeson7132 11 місяців тому +1

      I cannot tell you how valuable this comment is

    • @DaRealViso
      @DaRealViso 11 місяців тому

      @trentonbeeson7132 Thanks. Happy that my brief knowledge of coding helped

  • @alphakelo
    @alphakelo 2 роки тому +7

    This was a really good tutorial and I learned a lot, is there any sort of health and damage system that you know of that would work along side this tutorial?

    • @justinbennett9998
      @justinbennett9998 2 роки тому

      Good question.

    • @Ytsssss364
      @Ytsssss364 Рік тому

      yeah - see my post above on similar question - but I'll answer here too. You need of course to have a Enemy Health Controller - a script that controls the Enemy's Health status. you attach it to your Enemy Controller. In that Enemy Health Controller script, you create a public function called DamageEnemy(float damageAmount) which defines how the Enemy takes damage. Usually it's something like: {currentHealth = currentHealth - DamageEnemy} -- sorry but youtube does not like "minus equals" using symbols you know what I mean -
      so then, in the Weapon Controller, when the HIT is being done, in the part where you're playing that animation controller - where the SetTrigger ("Hit") is happening - well, you actually made a hit - the enemy flinches with its "Hit" animation and "bleeds" a "Blood particle" that's instantiated. That's where you wanna then take off some Enemy|Health - so here you code something like other.gameObject.GetComponent().DamageEnemy(damage); where "damage" is defined as a float in the WeaponController script -
      good luck

  • @GunzzYT
    @GunzzYT 2 роки тому +2

    ok, so i had this problem where my sword would swing but it was stuck in the attack animation(it wouldnt go back to idle animation). I had to click twice on my mouse btn in order to go back to idle and then i could attack again, so my solution was: Put the Anim.SetTrigger("Attack"); also in the ResetAttackCoolDown() method. That fixed it for me.

  • @Franos_official_
    @Franos_official_ 11 місяців тому +1

    Can someone copy the script here becose it didn't work

  • @justinbennett9998
    @justinbennett9998 2 роки тому +3

    I found an open sourcish project thats aiming to create a custom launcher for everquest trilogy and its being ported over to unity. I REALLY appreciate the unity videos ive found because i habe NO idea ehat im doing yet and your tutorials are extremely helpful. Youve become a huge part of a dream thats coming true. Thank you.

  • @arachnid5669
    @arachnid5669 2 роки тому +4

    Really well explained and easy to follow, thanks for making!

  • @MaskedYemeni1
    @MaskedYemeni1 5 місяців тому +1

    How to get Code pls i am big fan :(

  • @pollisgaming3168
    @pollisgaming3168 Рік тому +1

    Hi, everything worked perfectly but I was just wondering if it is necesary for the object's colliders to be on trigger since when I have them on trigger I can just walk through them. Ty for reading

  • @jojikYT
    @jojikYT 2 роки тому +2

    Aren't animation events better then coroutines in this case? Much easier to control and no timing problems.

    • @ZygerGFX
      @ZygerGFX  2 роки тому +1

      yes they are i didnt bother showing those since this is more of a tutorial on getting the basic weapon mechanics. but you're totally right

    • @Omnivoid22
      @Omnivoid22 Рік тому

      Now i gotta look up animation events? If i want something to end when animation ends. thats what i need to use?

  • @jamesclements9448
    @jamesclements9448 2 роки тому +12

    You did a great job with this tutorial. You are going to have a great career in game dev ahead of you.

  • @monkeyrobotsinc.9875
    @monkeyrobotsinc.9875 Рік тому +1

    this is nice but theres so much extra BS about "you can do it like this or like this or i like to do it like this" which is just too much babble. and overall talking just too fast anyway. i recommend chilling out some. this is too hyper.

  • @toongenie
    @toongenie 2 роки тому +2

    love this system, very easy to understand and works great! thanks for sharing

    • @ZygerGFX
      @ZygerGFX  2 роки тому +1

      thanks I appreciate it !

  • @BobTheGreatGoober
    @BobTheGreatGoober 7 місяців тому

    I Cant Drag In Da Anims And Make A New Trigger :( (i found out that i didnt select the sword and when i did and then looked in the animations they were there no worries)

  • @canalataquerapido
    @canalataquerapido 2 роки тому +1

    i like your channel thanks!

  • @MorphingGrid101
    @MorphingGrid101 2 роки тому +2

    Thank you so much Zyger!
    Very cool! 👍

  • @phonix374
    @phonix374 2 роки тому +1

    Thank you zyger realy cool tutorial you saved my life

  • @jojam.o
    @jojam.o 10 місяців тому +1

    probably the best unity tutorial for fps melee combat ive come across, thank you.

  • @nathanielgmoyon4772
    @nathanielgmoyon4772 Місяць тому

    Thank you for this amazing tutorial

  • @stopmotionnoob5053
    @stopmotionnoob5053 8 місяців тому

    Somone how i have 26 errors

  • @aaronludwig8150
    @aaronludwig8150 2 роки тому +1

    Phenomenal.

  • @cosmocourtois3345
    @cosmocourtois3345 2 роки тому +8

    I'm probably not the first to say this, but it is so nice to hear a girl talk for once in a male-dominated platform, especially in the game development community. Thanks!

  • @AleksandarDaGr8
    @AleksandarDaGr8 Рік тому +1

    Great tutorial! Only thing I'm a little confused on is how to have the enemy lose HP. was think it would make more sense to have the collision be handled by an enemy controller script and access a variable from the weapon called damage then if the OnTriggerEnter for if the enemy touches the swords hitbox to subtract the damage from health

    • @Ytsssss364
      @Ytsssss364 Рік тому

      naw, you're gonna have to create in your Enemy Health Controller a function where it takes the damage. Say, DamageEnemy. Then in the WeaponController, you're going to GetComponent

    • @Ytsssss364
      @Ytsssss364 Рік тому

      SORRY i used minus equals for code and it did it above as a "strikethrough" currenHealth minus equals damageAmount etc above, not strikethru lol

  • @erincristall
    @erincristall Рік тому

    I got up to the point where I have an attack animation and an enemy that goes into the idle animation, but when I actually attack the enemy, it doesn't do anything like the colliders aren't detecting. I am very confused because I pretty much just copy/pasted everything you did.

  • @brownie4672
    @brownie4672 2 роки тому

    hey you might not see this, but i am getting this error where it says "wc does not exist in this context." please help

  • @jmiahbullfrog
    @jmiahbullfrog Рік тому

    Mine doesnt show the sword, can attack and attack cool down on weapon holder

  • @chrismations9191
    @chrismations9191 2 роки тому

    K ima watch this after school for my game!

  • @syafiqaffandi4427
    @syafiqaffandi4427 Рік тому

    Hi @zyger, i need some help and im hoping you see this as it is my final year project, i would like to know how i can make my AI enemy to not be able to walk through the player or the trees bcs when i activated the isTrigger, he seems to be able to pass through everything

    • @ZygerGFX
      @ZygerGFX  Рік тому

      you can have 2 colliders on it. One which is OnTrigger and the other that isn't. You could also write a script that checks the distance between the enemy itself and the player and makes it stop moving when it reaches a certain distance value. Best of luck

  • @tronstein6342
    @tronstein6342 2 роки тому

    thank's a lot:;;;

  • @Darkziss0
    @Darkziss0 2 роки тому

    Thank!

  • @wowgames3035
    @wowgames3035 2 роки тому

    nice

  • @user-bj9vk1wl6q
    @user-bj9vk1wl6q 2 роки тому +2

    code is so poop

    • @quinnncy4703
      @quinnncy4703 2 роки тому

      then why did you watch the video?

  • @oggy4019
    @oggy4019 2 роки тому

    how to do auto swing every 1 sec when holding mouse0? thanks in advance!

    • @IrfuTuber
      @IrfuTuber Рік тому

      Input.GetMouseButton instead of Input.GetMouseButtonDown will work

  • @alsowow
    @alsowow Рік тому

    How would i have the enemy lose health? I thught that you would go over it but apparently not

    • @ZygerGFX
      @ZygerGFX  Рік тому

      when you detect the enemy getting hit just decrease their health like health-=10;

    • @alsowow
      @alsowow Рік тому

      @@ZygerGFX I'm relatively new to coding so if you could elaborate that would be great

    • @ZygerGFX
      @ZygerGFX  Рік тому

      @@alsowow well in your code you detect the enemy getting hit so if you followed the video that would be in the enemy script under OnTriggerEnter decrease the enemies health like: health -= amount;
      Health, is just a variable that you can set to whatever number you want and amount is either a variable or could just be a number of how much you want to decrease the health by.

  • @alphakelo
    @alphakelo 2 роки тому

    Hi, Im pretty new to unity, but I have copied down your script (up till 10:39) and everything seems correct but when I click nothing happens? Can someone please help?

    • @ZygerGFX
      @ZygerGFX  2 роки тому

      use debug.log to check if the function is being called. if it is then maybe something with the animations. and if not you probs not calling the function or input isnt being detected

    • @alphakelo
      @alphakelo 2 роки тому

      @@ZygerGFX Oh my god, thank you so much

  • @TheJuggernaut.
    @TheJuggernaut. 2 роки тому

    Every time I press the attack button, it does not work, what do I do? Is there a way to change the attack button to the space button?

    • @quinnncy4703
      @quinnncy4703 2 роки тому

      yeah, change the input from left clikc to spacebar

    • @TheJuggernaut.
      @TheJuggernaut. 2 роки тому

      @@quinnncy4703 Could you elaborate?

    • @quinnncy4703
      @quinnncy4703 2 роки тому

      @@TheJuggernaut. on the part that is like GetInput(mousebutton) change it to spacebar

    • @TheJuggernaut.
      @TheJuggernaut. 2 роки тому

      @Quinnncy You wouldn’t mind elaborating further, would you? Like instead of which line, should I add a correct one?

  • @johnathaninmanjr2629
    @johnathaninmanjr2629 2 роки тому +2

    Great vid, crystal clear and easy to follow , tyvm!

  • @lewaplay
    @lewaplay Рік тому +1

    poor