Attack 2 enabled collider appears before Attack 1 disabled collider Causes Attack 2 collider Enable to be missing

I’m making is a 3D act game

I have a question as in the title

when Attack 2 Enable Collider Immediately Attack 1 Disable Collider

The result is that Attack 2 collider is not enabled correctly, causing the attack to fail.

How to solve this problem

This is my C script

public void EnableWeaponCollider(int isEnable)
    {
        //
        if (weapon != null)
        {
            var col = weapon.GetComponent<Collider>();

            // 
            if (col != null)
            {
                if (isEnable == 1)
                {
                    col.enabled = true;

                    // 
                    if (disableColliderCoroutine != null)
                    {
                        StopCoroutine(disableColliderCoroutine);
                    }
                }
                else
                {
                    // 
                    disableColliderCoroutine = StartCoroutine(DisableColliderAfterDelay(col, 1f));
                }
            }
        }
    }

By debugging!

Sounds like you wrote a bug… and that means… time to start debugging!

By debugging you can find out exactly what your program is doing so you can fix it.

Use the above techniques to get the information you need in order to reason about what the problem is.

You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

Remember with Unity the code is only a tiny fraction of the problem space. Everything asset- and scene- wise must also be set up correctly to match the associated code and its assumptions.

My first guess would be inappropriate use of coroutines.

Is this just a cooldown timer? Then make it a cooldown timer.

Cooldown timers, gun bullet intervals, shot spacing, rate of fire:

Coroutines are NOT always an appropriate solution: know when to use them!

“Why not simply stop having so many coroutines ffs.” - orionsyndrome on Unity3D forums

No this is not cooldown timer

Maybe I should describe my project more accurately

This is my project

https://www.youtube.com/watch?v=LL5_9uegJJw

Attack 1 → Attack2 (or 3 )

Probabilistic missing collider enabled

The reason is like the picture in my post

How to solve the problems caused by this sequence

Again, by debugging. See above.