Hey Everyone,
Hopefully someone can help me out with this. I have a 3 hit combo system setup using a spooler class and I’m running into a problem with my first animation. I’m pretty sure it’s because my spooler’s allowing enough time to continue the combo that if they don’t press the button again, it’s able to play the first attack twice. So my question is, how can I make this only play once? Here’s my code:
void HandleInput()
{
if (Input.GetKeyDown(KeyCode.V) && canAttack)
{
if (firstAttackWindow.isOpen == false)
{
animCont.SetInteger("comboCounter", 1);
attackStage = 1;
firstAttackWindow.Start();
}
else if (secondAttackWindow.isOpen == false)
{
animCont.SetInteger("comboCounter", 2);
attackStage = 2;
firstAttackWindow.AddWindow(secondAttackWindow.window);
secondAttackWindow.Start();
}
else
{
animCont.SetInteger("comboCounter", 3);
attackStage = 3;
EnterAttackCooldown();
}
}
And here’s my spooler class:
public class Window
{
public float window;
public float windowSize;
private MonoBehaviour caller;
public bool isOpen = false;
public Window(MonoBehaviour _caller, float _window)
{
this.window = _window;
this.caller = _caller;
}
public void Start()
{
this.windowSize = this.window;
caller.StartCoroutine(DoWindow());
}
public void AddWindow(float _amount)
{
this.windowSize += _amount;
}
IEnumerator DoWindow()
{
this.isOpen = true;
while (this.windowSize > 0.0f)
{
this.windowSize -= Time.deltaTime;
yield return null;
}
this.isOpen = false;
}
public void Stop()
{
caller.StopCoroutine(DoWindow());
}
}
I know the reason why the animation is even allowed to play twice; it’s because the comboCounter stays at 1 until the window closes and resets it. The problem here is I can’t alter the number of the combo counter otherwise it won’t transition to the 2nd and 3rd phase of the attack. Any help is appreciated.
Thanks,
-Kaze-