Best way to create multi-directional melee combos?

zoicelols

Member
I have an ability starter for each of the 4 run directions that only start if one specific direction and the attack button is used. I want to create a combo system in which each direction has a 3 attack combo for a total of 12 different attack animations that can be intermixed depending on how far I am into the combo. One to three. Im setting up a sort of sword dance that I want to be able to have this system work as so.

Example:

When Firing an attack the first of three animations is played and if it is quickly repeated the second and then the third if pressed a third time. But say if I use up attack and then back attack and then left attack one after the other I want it to play up attack combo 1, back attack combo 2 and left attack combo 3. So whichever attack is used first will use the first animation in a set of 3 according to the direction and then the second will fire the second and then the third.

What I dont want is attack up is combo 1 then attack back is combo 1 and attack left is combo 1 of each set of 3 directional animation sets. I need it to continue the chain of 1, 2, 3.
 
Last edited:

Justin

Administrator
Staff member
You'll want to create a new AnimatorAudioStateSelector that uses the input/past inputs to determine which parameter should be set. This will allow you to then play a different animation based on the current game state.
 

zoicelols

Member
You'll want to create a new AnimatorAudioStateSelector that uses the input/past inputs to determine which parameter should be set. This will allow you to then play a different animation based on the current game state.
If I were to input a way to ask for which substate is currently active into an ability starter, how would I write it? I might be able to use that to get the same result if i create 3 different use abilities per direction and then each of them can only be started according to which substate is active for the combo?
 

Justin

Administrator
Staff member
I'm not completely following that method, but using the selector method is your best option. This will allow you to use the same ability and is actually what it is designed for. You can start by creating a new selector based off of the Sequence selector and then go from there.
 

zoicelols

Member
I'm not completely following that method, but using the selector method is your best option. This will allow you to use the same ability and is actually what it is designed for. You can start by creating a new selector based off of the Sequence selector and then go from there.
I actually want different damage and force direction on each combo 1-3 for each attack. Also i want 4 different abilities coresponding to each of the 4 movement directions. But i want to be able to chain together the 4 directional abilities in between their 1-3 combo animations and continue with the next number combo the last ability left off at. So I cant use one ability for all of them. With a new selector created to account for this situation would the selector be able to detect which one comes next from the last ability? Or can it only detect the same ability's audio animator selector specified states?

Is there a way to ask for a detection of which animator parameter is currently set within code? Like i want to say : if slot0 substate = 1 (combo 1) {and then I press a different direction attack} transition to substate 11. As example

Maybe im not understanding the capability.

I ask this because I want it to be able to go 1,2,3 for animation order. Like a category. Forward 1,2,3. Backward 1,2,3. Right 1,2,3. Left 1,2,3. If i input forward attack, left attack, forward attack i need it to transition to: forward 1, left 2, forward 3. Always 1,2,3 and then restart back to 1 after a timer which the sequence selector already has. But i do need 4 seperate abilities.

Also actually I need the combo to only be capable of continuing to the next is using the next attack during the last one. If you wait until any attack animation is over before pressing another attack then the combo resets back to 1 and will use the combo 1 animation of the specified input direction. So quick succession of attacks is the only combo way.
 
Last edited:

Justin

Administrator
Staff member
Also i want 4 different abilities coresponding to each of the 4 movement directions.
What do you mean by abilities?

Is there a way to ask for a detection of which animator parameter is currently set within code?
Yes, you can get a reference to the AnimatorMonitor and retrieve the parameters from there.

Ultimately the best method for this is the one that makes the most sense to you. I would personally use the Animator Audio State Set Selector to select a new state for each attack (which you can then use the state system to adjust the damage/force), but if you find that completely creating a new ability works best then that's the method that you should use.
 

zoicelols

Member
What do you mean by abilities?


Yes, you can get a reference to the AnimatorMonitor and retrieve the parameters from there.

Ultimately the best method for this is the one that makes the most sense to you. I would personally use the Animator Audio State Set Selector to select a new state for each attack (which you can then use the state system to adjust the damage/force), but if you find that completely creating a new ability works best then that's the method that you should use.
What I mean by abilities is I have 4 Use abilities using the ability starter. Each are activated by holding either up, down, left or right + fire1. Like super smash bros Controls but 3D. Then each action id 1 through 4 are tied to 4 different attacks on the same sword. For each attack I need 3 combo moves. 1-3. So each has 3 animator audio states for a total of 12 with all 4 attack abilities. What I dont understand is how to create a new animator audio state selector for this special case that will be activated on only 1 of the 4 melee weapon components at a time and have it detect what the last input was as well as detect what stage the combo is at currently so it knows where to leave off from while switching between the 4 melee weapon component animator states. I need it to be capable of going from a combo 1 from melee weapon component 1 to combo 2 from melee weapon component 2 and then be capable of going back to melee weapon component 1 for combo 3. Skipping the sequence of combo 2 from melee weapon component 1.

Is there any possible way I could meet you on discord at any time? It would only take like less 2 minutes to explain
 

Justin

Administrator
Staff member
I see what you are going for now. Within the selectors you can add event listeners which will then allow you to detect when the character is attacking. From here you should be able to determine which attack animation that you want to play next. This will be a more complicated selector but this type of requirement is what it was designed for so with some creativity you should be able to get one working well. Let me know if you find any limitations with the selector that may require a refactor of the class.
 

zoicelols

Member
Before I try the event listener would you mind telling me if this process is also a possibility to solve my issue? This is not actually working though as it brings errors. screen shot below. Maybe I'm not understanding how to type this out properly or its not possible with this method?
This is my AttackDance script that I copied and added from the sequence animator audio state selector.


Code:
       /// <summary>
        /// Returns the current state index. -1 indicates this index is not set by the class.
        /// </summary>
        /// <returns>The current state index.</returns>
        PlayerInput playerInput;
        public override int GetStateIndex()
        {
           
            if (!playerInput.GetButton("Right") && (!playerInput.GetButton("Backward") && (!playerInput.GetButton("Left"))))
            {

                if (playerInput.GetButton("Forward") && (playerInput.GetButtonDown("Fire1")))
                {


                    return 0;
                     


                }


               
            }
            return m_CurrentIndex;

        }
1550


1551
 

Justin

Administrator
Staff member
It's really tough to debug code without actually playing with it but my first guess is that playerInput is null. You'll want to insert a breakpoint and step through the function.
 

zoicelols

Member
I see what you are going for now. Within the selectors you can add event listeners which will then allow you to detect when the character is attacking. From here you should be able to determine which attack animation that you want to play next. This will be a more complicated selector but this type of requirement is what it was designed for so with some creativity you should be able to get one working well. Let me know if you find any limitations with the selector that may require a refactor of the class.
How would I specify asking for when my character is "attacking" through the event?
 

Justin

Administrator
Staff member
You can do so with the OnCharacterItemAbilityActive event:

 

zoicelols

Member
I am trying to follow the item abilities documentation you linked but instantly come across this problem in code. I'm a noob when it comes to this.

Code:
using UnityEngine;
using Opsive.UltimateCharacterController.Input;
using Opsive.UltimateCharacterController.Events;
using Opsive.UltimateCharacterController.Character.Abilities.Items;



namespace Opsive.UltimateCharacterController.Items.AnimatorAudioStates
{
    /// <summary>
    /// The Sequence state will move from one state to the in a sequence order.
    /// </summary>
    public class AttackDance : AnimatorAudioStateSelector
    {


        public void Awake()
        {
            EventHandler.RegisterEvent<ItemAbility, bool>(gameObject, "OnCharacterItemAbilityActive", OnItemAbilityActive);
        }



        [Tooltip("Resets the index back to the start after the specified delay. Set to -1 to never reset.")]
        [SerializeField] protected float m_ResetDelay = -1;

        PlayerInput playerInput;

        public float ResetDelay { get { return m_ResetDelay; } set { m_ResetDelay = value; } }

        private int m_CurrentIndex = -1;
        private float m_EndTime = -1;
 

Justin

Administrator
Staff member
Unfortunately I am not able to debug a complete set of custom code. If you're interested I do have a limited number of consulting hours (in the FAQ) which I'd be able to help you get a selector working the way that you want it to. With that said if you have a specific question on how something works from the API I'd be happy to help.
 

Justin

Administrator
Staff member
My current rate is $125/hour and we can do it through discord or I could just create the selector and send it to you. If you send an email to support@opsive.com we can go through the specifics as well as timing.
 
Top