Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Suggestions for an AI with Combo Inputs

Discussion in 'General Discussion' started by Laximata, Jun 12, 2021.

  1. Laximata

    Laximata

    Joined:
    Jun 12, 2021
    Posts:
    6
    Hi All,

    So I've been thinking about handling my AI ( simpliest possible ) for a fighting game/beat em up. ( well my goal is to make it look like a boss rush but still abit looks like a fighting game or something similar to 2D Arena-style )

    So far the player can do combos and air juggles, but I'm struggling for the AI to make these inputs ( I can make them do simple ground combos but air combos is a bit struggling ).

    I wanted to somehow do an execution of launching the enemy on air, jump and do one air slash attack, jump and do another air slash attack. I'm going back and forth to this idea or just make a pre-made AI that will have fixed Animator Controller Machine paths to what combo it will do... which means I will also have to remove the air juggle mechanic and just do static air combos ( where when player attacks, they just stay on air until the end of attack animation )

    Here's the base product of what I did. I'm probably making this too complicated for a solo Programmer / Animator.

     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,337
    "Is the enemy in air?"
    "Can it be reached with an attack in time?"
    "If yes, launch an attack at the predicted enemy position".

    Basically if the enemy is midair, calculate where it is going, and hit/blast at that point. It is similar to writing a turret that can shoot down hand grenades.

    Be aware that if you do that, you may end up with a "Mortal Kombat Walker" AI, which are hard to kill but not fun to play against.

    It may be easier to just record attack sequence, but that can also be less reliable.
     
    wasi5544332211 likes this.
  3. Laximata

    Laximata

    Joined:
    Jun 12, 2021
    Posts:
    6
    The positioning won't be a problem for now as all the combos would have a fixed trajectory. The AI can locate the target right now. The problem would be is to perform sequence of button presses.

    I made a weird approach of using IEnumarators to make the AI perform attacks as if it's inputing a combo ( like pressing this button only for 0.1f second before letting go and pressing another button ), which works, but granting I still have little knowledge in Unity and just putting simple codes I know together, I'm not sure if IEnumerator would affect the performance of the game.
     
  4. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,799
    Use a timer and increment using Time.deltaTime and reset/execute after the duration set in your IEnumerator. I would not call what you are doing AI as it does not weight and train. It is really a set of conditionals to be met or not to generate the motion wanted from Mecanim or procedural IK etc.