How To Make a Combo System in Unity in Less than 7 Minutes

  Рет қаралды 101,274

DanCS

DanCS

Күн бұрын

Пікірлер: 130
@LORD---BrazilianSoldier
@LORD---BrazilianSoldier 2 жыл бұрын
Straight to the point, very well explained, thank you so much
@renzellelaurenceapolinario7925
@renzellelaurenceapolinario7925 3 жыл бұрын
My animation stop on attack 1
@daveyyyyyyy
@daveyyyyyyy 10 ай бұрын
Same
@SozINh
@SozINh 7 ай бұрын
Same
@NameUnknown-
@NameUnknown- 3 жыл бұрын
With the way you are doing it, triggers would be better to use/manage instead of booleans
@vietanhnguyen1415
@vietanhnguyen1415 2 жыл бұрын
OMG this is the best combo tutorial i learn on KZbin, if you can, please make more video about this, very much appreciate
@XadegamerOfficial
@XadegamerOfficial 3 жыл бұрын
the cooldownTime variable is not used
@reibisco
@reibisco 2 жыл бұрын
That's what I thought too.
@thunderhawk4592
@thunderhawk4592 3 жыл бұрын
only plays to the first and some times second(if u spam it) animation never the third
@lazyonii-chan3885
@lazyonii-chan3885 Жыл бұрын
my idle animation just stopped after I pressed the attack button once, what should I do?
@crankyastrologer96
@crankyastrologer96 Жыл бұрын
thank you the explanation and concept is the best but i would like to add some changes that i did which made the code work smooth like butter 1. remove all the things in the if statement after noOfClicks in the onClick void 2. instead of that add exit time to all the animations (entering animation and exitig animation) 3 make a var reference in onClick void like : var Attack1 = anim.getbool("hit1") 4 than add in only the second if statement where you deleted earlier : && attack1 == true 5. also remove all the setbool false from onClick and thats it. if you were having problems with animations gliching this fixed it for me and should do it for you too thank you
@Gamedial
@Gamedial Жыл бұрын
Can you show your code? I'm a bit confused by the explanation.
@crankyastrologer96
@crankyastrologer96 Жыл бұрын
Yes
@crankyastrologer96
@crankyastrologer96 Жыл бұрын
MAKE SURE TO ADD EXIT TIME OF ABOUT 7 SECONDS Void Attacks() { if (playerAnim. GetCurrentAnimatorStateInfo(8).normalizedTime > 0.7f && playerAnim. GetCurrentAnimatorStateInfo(0). IsName("at1")) ( playerAnim.SetBool ("att", false); if (playerAnim.GetCurrentAnimatorStateInfo().normalizedTime > 0.7f && playerAnim.GetCurrentAnimatorStateInfo(0). IsName("at2")) t playerAnim.SetBool("att2", false); if (playerAnim.GetCurrentAnimatorStateInfo().normalizedTime > 0.7f && playerAnis.GetCurrentAnimatorStateInfo(0). IsName("at3")) playerAnim.SetBool ("att3", false); noOfClicks = 0; if (Time.time - lastClickedTime > MaxComboDelay) noofClicks = 0; I if(Time.time> nextFireTime) if(Input. GetMouseButtonDown(0)) { onClick(); } if (noOfClicks == 0) playerAnda.SetBool ("att", false); playerAnim.SetBool ("att2" false); playerAnda.SetBool ("att3" false); attack = false; } void onClick() { var atti playerAnda.GetBool ("att"); attack = true; LastClickedTime = Time.time; noofClicks++; if(noofClicks == 1) playerAnim.SetBool ("att", true); noofClicks = Mathf.Clamp(noofClicks, 0, 3); if(noofClicks >= 2 && att1 = true) playerAnim.SetBool ("att2", true); if (noofClicks >= 3) playerAnim.SetBool ("att3", true); }
@crankyastrologer96
@crankyastrologer96 Жыл бұрын
@@Gamedial hope this helps
@klayver4068
@klayver4068 Жыл бұрын
I don't understand
@misakidev1366
@misakidev1366 2 жыл бұрын
fast and concise, great tutorial bro.
@stylie473joker5
@stylie473joker5 2 жыл бұрын
Instantly subbed. a really thoughtful and great video
@VayoDev
@VayoDev 3 ай бұрын
how did you use the cooldown time? It's never referenced?
@javidwaldron8377
@javidwaldron8377 8 күн бұрын
I was just about to comment this
@__Rizzler__
@__Rizzler__ 7 ай бұрын
imma rebuild the mongol empire with this one in unity
@Timtowtdi-oop
@Timtowtdi-oop 2 жыл бұрын
Fantastic! Just what I needed.
@seoresoyannwo7545
@seoresoyannwo7545 Ай бұрын
My animation stops on attack1 how can i fix this
@pewpew518
@pewpew518 3 жыл бұрын
I've made a similar system but more modular and scalable. i think your doing a lot of unnecessary stuff here. eg dont use state info. The operation itself is a bit expensive on performance. on top of that your are comparing strings in "IsName" thats two expensive operations that could cause frame spike. The system does not scale. you have a bool parameter for every swing. what if you have different weapons? or more combos? In my implementation i use for loops to keep track of combo being performed and anim events to add frame specific events such as animation cancel etc. Also not sure of you have a "Click expiry timer" . lets say you have a combo of 5 and player taps button 5 times really fast you dont want ther player to get locked into that 5 move combo for whatever length of time the combo lasts for. it doesn't feel good so you need a expiry time for each button pressed . also don't use anim state transition. instead player animation from code using animator.play or animator.crossfade
@Mikelica69
@Mikelica69 3 жыл бұрын
true
@negimox
@negimox 3 жыл бұрын
can you share the code your implementation of combo system?
@pewpew518
@pewpew518 3 жыл бұрын
@@negimox namespace Player_Controller.Combat { public class PCtrlWeaponAttack : PCtrlBase { protected float InputBufferTimer; protected int heavyAttackInputBuffer; protected int lightAttackInputBuffer; protected bool lockOn; protected float InputBufferTime = 0.5f; protected float animationFadeTime = 0.2f; protected string animationPrefix; protected Animator animator; protected Rigidbody rb; protected GameObject weaponBone; Dictionary heavyAttackCombo; Dictionary lightAttackCombo; void Start() { animationPrefix = Weapon.anim_WeaponAttackPrefix.ToString(); rb = gameObject.GetComponent(); InetializeHeavyAttackCombo(); InetializeLightAttackCombo(); animator = gameObject.GetComponent(); Weapon.Inetialize(gameObject, weaponBone); } // Update is called once per frame void Update() { if (PStatus.isDodging || StatusIsJumping || StatusIsFalling || PStatus.isCastingControlLock) { AnimationEvent_ResetHeavyAttackCombo(); AnimationEvent_ResetLightAttackCombo(); return; } // light attack buffer if (heavyAttackInputBuffer != 0 || lightAttackInputBuffer != 0) { if (Utilities.SimpleTimer(ref InputBufferTimer, InputBufferTime)) { heavyAttackInputBuffer = 0; lightAttackInputBuffer = 0; } } // LIGHT ATTACK if (lightAttackInputBuffer > 0 && heavyAttackInputBuffer == 0) { PStatus.isAttacking = true; for (int i = 1; i 0 && lightAttackInputBuffer == 0) { PStatus.isAttacking = true; for (int i = 1; i
@pewpew518
@pewpew518 3 жыл бұрын
@@negimox namespace Player_Controller.Combat { public enum AttackType { _LightAttack_, _HeavyAttack_ } public class Attack : MonoBehaviour { public string animation; public bool hasStarted; public bool hasPerformed; public Attack(string _animation) { hasStarted = false; hasPerformed = false; animation = _animation; } } }
@pewpew518
@pewpew518 3 жыл бұрын
@@negimox I havent optimized the code yet. i got it to work for prototyping. In a nutshell this system scales from 1 to infinity which means you can have infinite number of moves in one combo set. also you pass a string in "animation prefix" say you have equiped a hammer just make animprefix = hammer then if you have those anims in your animator the system will play that anim
@defifire9980
@defifire9980 3 жыл бұрын
Good tutorial but a lot of fails... you don't use the cooldown... the boolean here is the worst idea possible when you have integers in the parameters and you don't explain how to modify the animations if you're stopped / walking :(
@funiprofrfr
@funiprofrfr Жыл бұрын
didnt have the model all i had was a bean so i don't know if i can or cant make the attack so can you make a tutorial for one without that model?
@angelkaki5707
@angelkaki5707 Жыл бұрын
I followed the guide but as soon as i hit start my player goes straight to attack mode without me pressing any key??? how do i make it so it attacks when i press left click??? Id appreciate any help[ ty!
@anussqadeer3181
@anussqadeer3181 Жыл бұрын
Will it work on invector character?
@filteredlava
@filteredlava 4 ай бұрын
My attack keeps stopping on attack one
@barax9462
@barax9462 2 жыл бұрын
Can you please help,,, When using certain animation from Mixamo,,, like a sword hit that make the characer chagne position,,, when i play them in Unity, once the animation finishes the character return to the original point where the animation started rather than where the animation finished,,, and it returns almost instantly in an unlikable way,,,
@mezloute3501
@mezloute3501 Жыл бұрын
Same bro, if i found something i'll tell you
@mezloute3501
@mezloute3501 Жыл бұрын
Okay, so I couldn't find a way about it, i have some clues about root motion, In the Animator component, check if the "Apply Root Motion" checkbox is enabled. BTW I found out that i can just deleted the position curve on the x axis for the animation to play and at the same position
@barax9462
@barax9462 Жыл бұрын
I really do appreciate it bro thanks alot 💯💯💯💯​@@mezloute3501
@Tamar_Dev
@Tamar_Dev 2 жыл бұрын
How do I make the code work for a UI Button for an android mobile? The input.MouseButtonDown(0) works everywhere on the screen
@lanefaulhaber875
@lanefaulhaber875 Жыл бұрын
Question: does the player continue to move if there is movement input while the attack animations are playing? I'm sure this could be easily fixed, but just curious.
@alexandresbolanosparker6093
@alexandresbolanosparker6093 Жыл бұрын
I have a problem in the controller "missing runtime animator controller" you know how to fix this?
@bellocktx5800
@bellocktx5800 2 жыл бұрын
We need more videos like this!
@berliananurien3754
@berliananurien3754 7 ай бұрын
THANK YOU SOOOO MUCHHHHH IT'S HELP ME A LOT!🔥
@Joe_334
@Joe_334 Жыл бұрын
How did you get the left hand to follow the grip on the dominant right hand? I really like the stance with that blade.
@DanCSS
@DanCSS Жыл бұрын
Check out animation rigging package
@Xeratas
@Xeratas Жыл бұрын
how does this work if the use clicks 10 times in half a second? Am i missing somthing or does that brick the combo?
@christopherball835
@christopherball835 2 жыл бұрын
Nice tutorial, very informative and concise. I have one issue though: Is there a practical way of speeding up the button down registering? I followed the tutorial, yet I noticed the animator doesn’t register every press if you mash repeatedly or quickly (just by watching the animator tab i see it not registered every mouse,key,and/or button press). Going for a hack and slash so really want the animations to activate and move on once that button mashing sets in; I have already tried speeding up animator itself and setting “Next State” for interruption source on animation transition.
@christopherball835
@christopherball835 2 жыл бұрын
Update: while watching the animator states, I notice after one complete “cycle” (going through all animations), it gets hung up on attack 2- the parameter for attack 2 just remains checked and the input doesn’t take unless I manually uncheck “attack 2” or just wait for it to lag and resolve itself after mashing it enough times. Still looking into this…
@DanCSS
@DanCSS 2 жыл бұрын
I think the best way to do it, and I did it wrong in this video is to use animation events, you can easily set when you want the next attack to begin, even set if you need to know when your attack ends.
@christopherball835
@christopherball835 2 жыл бұрын
@@DanCSS Admittedly as a novice, I’m stuck rn. What should the function be for the animation event. I’ve been trying to reverse engineer the right function using OnClick, and also the lines of code from the update function in this vid. How should I write the function?
@DanCSS
@DanCSS 2 жыл бұрын
I can't go in depth, but what you would need to do, is have an animator parameter of type trigger and basically create a script on the gameobject the animator is on, and then activate that trigger through a public function, and then in the animation add an animation event, and then find your public function there. I can't really go much further than this in the comments but I can recommend a video tutorial: kzbin.info/www/bejne/f3-tnqSnqq2UsJY
@christopherball835
@christopherball835 2 жыл бұрын
@@DanCSS So I actually was at the point where I had everything you just had mentioned (animation event set up at the end, parameters were changed triggers, etc) I’m just actually confused on what the public function would be. Where I should actually be looking at in the code?
@hendryanlim4923
@hendryanlim4923 2 жыл бұрын
hi brother, i have a problem when i press attack button and move character with W A S D at the same time, my character will attack while moving.. so i want my character to stay in place when attack, is there any way to do it?🤔🤔
@DanCSS
@DanCSS 2 жыл бұрын
Try to look up animation cancelling
@hendryanlim4923
@hendryanlim4923 2 жыл бұрын
@@DanCSS I've been looking for information about animation canceling but it's still not helpful in my problem, can you give another solution? I appreciate all your help😉
@hendryanlim4923
@hendryanlim4923 2 жыл бұрын
@@DanCSS nvm, I've found the solution and for people wanting the solution, I used this code in the player movement script: // on your player controller have a reference to your animator // and stick this code before any movement is preformed if(anim.GetCurrentAnimatorStateInfo(0).IsName("The name of the animation, in the video the name is hit1)) { returns; } btw, thanks for making this tutorial. That's very helpful
@raphaelguitarx5931
@raphaelguitarx5931 Жыл бұрын
Example if you have a float of player movement set that one = 0 lastTimeInput = Time.time; numOfInputs++; if (numOfInputs == 1) { punchC1 = true; moveSpeed = 0;
@mygamedevjourney5290
@mygamedevjourney5290 3 жыл бұрын
Superb content and Thank you!!🙂
@tanjiro9695
@tanjiro9695 2 жыл бұрын
and, what is the purpose of variable cool down time?
@DanCSS
@DanCSS 2 жыл бұрын
It’s something that I deleted so it accidentally stayed in, sorry
@OmeedNOuhadi
@OmeedNOuhadi 2 жыл бұрын
Awesome way to have an attack system.
@DanUAPas
@DanUAPas 2 жыл бұрын
where did you get the movement script, I think that mine isn't compatible with yours.
@a1980125
@a1980125 2 жыл бұрын
Good tutorial,thank you.😊
@UlisesFreitas
@UlisesFreitas 3 жыл бұрын
The script is no longer available please check this and reupload, Thanks.
@DanCSS
@DanCSS 3 жыл бұрын
Sure, thank you for the information. It is now fixed
@UlisesFreitas
@UlisesFreitas 3 жыл бұрын
@@DanCSS Thanks a lot.
@DanCSS
@DanCSS 3 жыл бұрын
@@UlisesFreitas It’s not a problem :)
@archieharrap5901
@archieharrap5901 2 жыл бұрын
using the exact script and hit1 stays true the whole time and hit2 never actually gets changed to true, meaning it loops animation for hit1 any fix for this?
@praisethemibbers8991
@praisethemibbers8991 Жыл бұрын
having same issue
@emretasdemiir
@emretasdemiir Жыл бұрын
@@praisethemibbers8991 still have some issues but i found the problem which it also happened to me, names of the parameters and the animations are same here but cant be in your animator, make them all same name or check your names of parameteres and animation states and use it in script accurately.
@jgstrinca
@jgstrinca Жыл бұрын
How could I make my character walk slower as soon as I hit?
@ashhalidrees7525
@ashhalidrees7525 Жыл бұрын
you can either use Rigidbody constraints to freeze position or either slow down by minimzing movement or velocity
@AaaAaa-lt6uy
@AaaAaa-lt6uy 3 жыл бұрын
We need tutorial about interaction fight animation between two characters like assassin's creed and shadow fight and mortal kombat
@DanCSS
@DanCSS 3 жыл бұрын
I’ll try to make it. Thanks for the feedback!
@LiamSwiftTheDog
@LiamSwiftTheDog 2 жыл бұрын
This is not very good and hard to manage.. I recommend having a trigger per attack button (eg. if you have light & heavy attack buttons, have a separate bool for each of those). Then you can just chain states together using 'LightAttack' or 'HeavyAttack' triggers, and it will just work. Though, if you want to prevent the player from triggering a state change too early, you can lower the exit time (often undesired as it'll always prematurely cut off your animation), or keep track of a bool called 'canDoNextCombo' or sth. Then at the beginning of combo move animations, set it to false. Then somewhere halfway or whenever it makes sense to be able to do the next part of the combo, set canDoNextCombo back to true. This also requires LightAttack and HeavyAttack to become booleans, as you will need to check on their 'false' state to exit the combo chain gracefully and prevent prematurely exiting it.
@generos1172
@generos1172 Жыл бұрын
Can u ggive me an example how u gonna start it and how u gonna end it with?
@Aaron-pb2bf
@Aaron-pb2bf 2 жыл бұрын
for some odd reason my first animation makes my character fall to the ground
@nuricemregumus6136
@nuricemregumus6136 2 жыл бұрын
Im subscribed instantly. Underrated
@tahercaballero7584
@tahercaballero7584 2 жыл бұрын
brother I have a problem that when I click the animation doesn't run, what are you saying it could be :C , I need to finish my final work :C. I wait your answer.
@gamingmaster6377
@gamingmaster6377 2 жыл бұрын
its me from an alt account, did you check the ld credentials?
@ettiolayinka6262
@ettiolayinka6262 Жыл бұрын
it didnt work and we didn't even used the coolTime in the script
@frankypappa
@frankypappa 2 жыл бұрын
Awesome tutorial. Any chance you could make it in 2D?
@DanCSS
@DanCSS 2 жыл бұрын
That is an amazing idea actually. I’ll do it
@frankypappa
@frankypappa 2 жыл бұрын
Awesome!! Subscribed btw!! Keep up the great work great content!! And thanks again looking forward to it! 😁
@neowb8495
@neowb8495 2 жыл бұрын
UP! is there a tutorial yet?
@glowraptor5228
@glowraptor5228 4 ай бұрын
does this work for 2d?
@bonse2000
@bonse2000 Жыл бұрын
link for script dsnt work
@부산-j5j
@부산-j5j Жыл бұрын
thank you. it's so useful
@supernoobr.d7880
@supernoobr.d7880 2 жыл бұрын
Hice lo que dijiste, no tengo errores con el scrip y las animaciones pero solo lanza un solo ataque xD
@LowLevelLemmy
@LowLevelLemmy Жыл бұрын
Was this motion captured by my Dad? 🤣🤣🤣🤣
@jred7333
@jred7333 Жыл бұрын
my guy just falls into the ground lmao
@minedantaken1684
@minedantaken1684 3 жыл бұрын
You're a lifesaver!
@supernoobr.d7880
@supernoobr.d7880 2 жыл бұрын
Una pregunta, ¿Cómo podría hacer para pasa de una pose normal a una pose de batalla?
@gabrielpetersen3434
@gabrielpetersen3434 2 жыл бұрын
Simples, tente con una bool que es true cuando en batalla y false cuando normal, criando una nueva blend tree para movimentación (mio español és péssimo, lo siento)
@supernoobr.d7880
@supernoobr.d7880 2 жыл бұрын
@@gabrielpetersen3434 Muchísimas gracias bro jajajaja ❤️
@ABATHINGAPEX
@ABATHINGAPEX 2 ай бұрын
Very classy very business-like until he said you can hit some dope ass combos HAHAHA SUB
@berkcanimdat
@berkcanimdat Жыл бұрын
adamsın sen i love it man
@supernoobr.d7880
@supernoobr.d7880 2 жыл бұрын
Muchas gracias bro!
@Johnnys_Manager
@Johnnys_Manager 24 күн бұрын
i love u bro😭😭😭😭😭😭😭😭😭😭
@enescubuk3312
@enescubuk3312 2 жыл бұрын
YOU DONT USE COOL DOWN TİME BRO WTF????
@GCTechReview
@GCTechReview Жыл бұрын
//cooldown time if (Time.time > nextFireTime) { // Check for mouse input if (Input.GetMouseButtonDown(0)) { OnClick(); // Actualizar el siguiente tiempo de disparo basado en el tiempo actual y el tiempo de enfriamiento nextFireTime = Time.time + cooldownTime; } } Cuando el tiempo actual (Time.time) es mayor que el siguiente tiempo de disparo (nextFireTime), se verifica si se ha realizado un clic del mouse (Input.GetMouseButtonDown(0)). Si es así, se llama a la función "OnClick()" y se actualiza el siguiente tiempo de disparo agregando el tiempo de enfriamiento (cooldownTime) al tiempo actual. Por lo tanto, puedes ajustar el valor de "cooldownTime" en el Inspector de Unity para cambiar el tiempo de enfriamiento entre los clics del mouse. Esto te permite controlar cuánto tiempo debe esperar el jugador antes de realizar otro golpe después de cada clic.
@AlfieGames2015
@AlfieGames2015 9 ай бұрын
I wat the model
@__MEETTEJANI
@__MEETTEJANI Жыл бұрын
Thank you
@Damian_DH
@Damian_DH Жыл бұрын
My man~
@mcsyf
@mcsyf 2 жыл бұрын
Thanks
@ps5games821
@ps5games821 3 жыл бұрын
Make more tutorials please
@DanCSS
@DanCSS 3 жыл бұрын
I will :D
@rafarodriguez4765
@rafarodriguez4765 2 жыл бұрын
Great
@collinsokoye6352
@collinsokoye6352 11 ай бұрын
Is this software development?
@SlothHuntOnYou
@SlothHuntOnYou 8 ай бұрын
why 60fps for tutorials=(((
Unity Destruction Tutorial in Less Than 5 Minutes
0:45
DanCS
Рет қаралды 4,4 М.
Melee Combat & Weapon System - Unity Beginner Tutorial
20:12
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
Unity VFX Graph - Sword Slash Tutorial
16:17
Gabriel Aguiar Prod.
Рет қаралды 140 М.
Modular Combo System for Combat in Unity
20:29
The Game Dev Cave
Рет қаралды 37 М.
Recreating Batman Arkham's Freeflow Combat | Mix and Jam
7:35
Mix and Jam
Рет қаралды 124 М.
MELEE COMBAT in Unity
21:07
Brackeys
Рет қаралды 1,6 МЛН
Creating an easy Ability System in Unity
7:08
TIMBER
Рет қаралды 105 М.
Unity - 2D Melee Combo System Tutorial
22:15
Sean Masai Hill
Рет қаралды 76 М.
COMBAT - Making an RPG in Unity (E11)
12:29
Brackeys
Рет қаралды 316 М.
How To Make Combo System in Unity With Mixamo
18:10
Panopticon
Рет қаралды 12 М.
How to work with humanoid animations in Unity
12:50
Unity
Рет қаралды 43 М.
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН