Need an Idea for Triple Click and Fourth Click

Hi All

Gosh, I really don’t like the amount of neste ifs you have there, so here is my own version

    //The amount of seconds the code will wait between each click
    public float ClickDelay = 0.2f;

    //How many click are currently registers
    private int _currClicks;

    //The current amount of time that hase passed since the last click
    private float _clickTime;

    // Update is called once per frame
    void Update () {

        CheckForClicks();
    }

    private void CheckForClicks()
    {
        //If we detected a new click, we increase _currClick counter, and reset the time since last click (_clickTime)
        //Note that his will not work on GetMouseButtonDown
        if(Input.GetMouseButtonUp(0))
        {
            _currClicks ++;

            //_click time is resetted at every click as we want the amount of time since LAST click, not since the first click
            _clickTime = 0;
        }

        //If there were no other clicks, stop all computations
        if(_currClicks == 0) return;

        //As long as the current time since last click, is smaller than the amount of time
        //we want our code to wait for a click, we junt increase the _clickTime timer
        if(_clickTime < ClickDelay)
        {
            _clickTime += Time.deltaTime;
            return;
        }

        //If the amount of seconds we want to wait has passed, we handel the curr amount of cliks and reset the values
        HandleClicks(_currClicks);
        _currClicks = 0;
        _clickTime = 0;

    }

    private void HandleClicks(int amountOfClicks)
    {
        //we hande each amount of clicks
        switch (amountOfClicks) {
            case 1:
                Debug.Log("Single Click");
            break;
            case 2:
                Debug.Log("Double Click");
            break;
            case 3:
                Debug.Log("Triple Click");
            break;
            case 4:
                Debug.Log("Fourth Click");
            break;
            default:
                Debug.Log("You've cliked: " +  amountOfClicks + " times");
            break;
        }
    }

This code works on any amount clicking. Note that I left a bit of work for you, as this code will wait until you are done clicking and handle that case (will wait for 100 clicks, and then call HandleCliks with 100). I think you want to stop to 4, so the user will not have to wait for extra seconds. You just have to add an extra if in the “if(Input.GetMouseButtonUp(0))” condition

Edit: I see that you edited your comment. Don’t do that, leave the question there even if you solve it, as there may be many who have your question and are looking for an answer