Hi, I am not sure if this goes to "animation" category or here but I have 2 events in animation called "EnableSecondAttack" and "DisableSecondAttack" then I just execute OnAttack(). Is this good approach or there is better solution ? If yes how I should do combo system ? Code (CSharp): bool canDoSecond = false; private void OnAttack() { if (_input.attack && !canDoSecond) { _animator.SetTrigger(_animIDAttack1); _input.attack = false; } else if (_input.attack && canDoSecond) { _animator.SetTrigger(_animIDAttack2); _input.attack = false; canDoSecond = false; } else _animator.ResetTrigger(_animIDAttack2); } private void EnableSecondAttack() { canDoSecond = true; } private void DisableSecondAttack() { canDoSecond = false; }
I recommend learning the "state machine" programming pattern. It maps extremely well to problems like this. Each of your if/else if blocks here would be represented by a state, and rather than having a messy spaghetti of variables like canDoSecond, you just track the current state of the state machine you're in.