Alternate Solllution and Combo system

Hey Brian, This is a question I’ve moved over from Udemy
Hey Brian I was curious about this also, I ended up with I guess a slightly different solution that seems to work pretty well I was just wondering about your thoughts on it also what kind of steps I would have to take to allow for special inputs ex light, light, heavy does a fireball.
So in my solution I created an extra button input for heavy attacks.

Added another array for heavy attacks in my player state machine

in my tick function I check to see if i am using a light or heavy attack and proceed to try combo attack like the course shows.
in my constructor I added an integer for heavy attack Index and did an if check to see depending on my input which array to switch between, (light or heavy). I’m able to switch between light or heavy attacks however I choose and cancel lights with heavy and vice versa which is what I intended but I feel like my solution isn’t super flexible and I was wondering if I should take a different approach if I wanted to make a combo system for special inputs like the fireball example above.
Also If I should make a separate thread so I don’t fill this question with bloat haha.
here is some of my code in my player attacking state.

public PlayerAttackingState(PlayerStateMachine stateMachine, int AttackIndex, int AttackIndexHeavy) : base(stateMachine) // adding attack ID into constructor so we know which attack to use
    {
        if (stateMachine.InputReader.isBasicAttack)
        {
            attack = stateMachine.Attacks[AttackIndex]; // assigning the attack value to the attack id when w/ pass this information into other states in statemachine
            FaceTarget();
            Debug.Log("Basic attack index" + attack.ComboStateIndex);
        }
        if (stateMachine.InputReader.isHeavyAttack)
        {
            attack = stateMachine.HeavyAttacks[AttackIndexHeavy];
            FaceTarget();
            Debug.Log("heavy attack index" + AttackIndexHeavy);
        }
        if(stateMachine.InputReader.isBasicAttack && AttackIndex > 0 )
        {
              AttackIndexHeavy = attack.ComboStateIndex;
        }
        if(stateMachine.InputReader.isHeavyAttack && AttackIndexHeavy > 0)
        {
              AttackIndex = attack.ComboStateIndex;
        }
    }

This isn’t a bad approach to heavy vs regular attacks, although I take a slightly different approach, having an AttackState and a HeavyAttackState. This sends the responsibility for reacting to a heavy or light attack to when we detect the attack combo, calling AttackState or HeavyAttackState based on the InputReader.IsHeavyAttack… By this same logic, you can also check for special attacks like the Fireball, and make that it’s own state as well.

1 Like

Privacy & Terms