Search Unity

How to make smooth attack combo in action game?

Discussion in 'Game Design' started by Xhitman, Jun 25, 2020.

  1. Xhitman

    Xhitman

    Joined:
    Oct 30, 2015
    Posts:
    452
    As shown in video, it basically works. However, I don't have the same "button pressing feeling" as other action game, final fight, street rage, or fighting game, like street fighter.

    I try the different attackResetTIme from 0.2f to 0.5f, but it does not work.

    Is there any thing like "button pressing frequency" that human prefer? Or any other attack combo design rule that Capcom or SNK follow?



    Code (CSharp):
    1. void FixedUpdate()
    2.     {
    3.         if (Input.GetKeyDown(KeyCode.F) && _humanSensor.ableToEnterCommanderRobot)      
    4.             TakeVehicle();
    5.  
    6.         Punch();
    7.     }
    8.  
    9.     void Punch()
    10.     {        
    11.         _animator.SetBool("Attack Combo", false);
    12.         if (Time.time < lastAttackPressTime + attackResetTIme)
    13.             _animator.SetBool("Attack Combo", true);
    14.  
    15.         if (Input.GetKeyDown(KeyCode.K))
    16.         {
    17.             lastAttackPressTime = Time.time;
    18.  
    19.             // play first attack only
    20.             // combo attack automatically transit in state machine
    21.             if (!_animator.GetCurrentAnimatorStateInfo(0).IsName("Punch_01"))
    22.                 if (!_animator.GetCurrentAnimatorStateInfo(0).IsName("Punch_02"))
    23.                     if (!_animator.GetCurrentAnimatorStateInfo(0).IsName("Kick_01"))
    24.                         if (!_animator.GetCurrentAnimatorStateInfo(0).IsName("Kick_02"))
    25.                             _animator.Play("Punch_01");
    26.         }
    27.     }
    28.  
     
  2. Serinx

    Serinx

    Joined:
    Mar 31, 2014
    Posts:
    788
    I'd say it's more dependent on the animations. You want the combo to continue only if you press the button near the end of the current animation. I'd set some events on your animation which allows the player to press the button and continue the combo. If they press the button too early or too late, the combo won't continue.
     
    williamomballa likes this.
  3. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    Some ways of accomplishing this.
    One way revolves around using the animator transitions, which I've tried and it gets a little difficult to keep track of.
    Another would be to use animations that are made to lead into each other, and keep track of the animation lengths. Use animation events to say when you can press attack again to register to continue the combo, and tell it that after the attack length, do the next attack.
    I've tried both before and I've had some moderate success with the second one.
     
    BrandyStarbrite likes this.
  4. Xhitman

    Xhitman

    Joined:
    Oct 30, 2015
    Posts:
    452
    What is the time between each button press you prefer? I mean you won't require player to press button per 0.1 sec in order to maintain combo.
     
  5. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    Normally, around the half way point of the animation. It gives time to press the button, or to decide you don't want to continue. That's how its worked for me anyways. I feel like timing button presses together is cooler than spamming together a string of inputs and watching the animations lag behind.
     
  6. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
    Now that is a good idea.
     
  7. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    3,546
    I know it’s anoying when people respond like this, but I personally think combos are over rated and prefer deliberate gameplay.

    MAYBE, maybe do animation cancels.

    But games like Devil May Cry make me think “Okay, thanks for the homework!”

    AND I think if you press the attack it should have a trade off.

    So let’s say you do an attack. It does 100% damage. At this point you can follow up with a second attack, but it only does 50% damage.
     
  8. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
    Due to an upcoming project I'm working on, I'm pondering on how to do this as well. I'm planning on prototyping a game that has combos in it. Would you guys say, that visual scripting is another good way to do this? Because a few people on this forum, have suggested it.
     
  9. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    I made my own graph based asset that strings together combo animations using the new input system and the animator crossfade function and honestly it's the best I've gotten it to work in both looks and functionality. So if you have a chance to use any kind of visual help then take it.

    The first revision of my code had it working as a reorderable list array and while it worked, it looked super messy and crowded.
     
    BrandyStarbrite likes this.
  10. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
    Interesting. Thanks for the advice.