I want to rotate a object on double tap ,Can any One help me with this?

I have two object A and B ,when i double tap on object A ,both the object will start rotating. i need when i tap on a A object should A should rotate and if B should rotate.

the following code i took from another post. I hope this can help

   if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began)
             {
                 tapCount++;
             }
             if (tapCount > 0)
             {
                 doubleTapTimer += Time.deltaTime;
             }
             if (tapCount >= 2)
             {
                 //What you want to do
                 doubleTapTimer = 0.0f;
                 tapCount = 0;
             }
             if (doubleTapTimer > 0.5f)
             {
                 doubleTapTimer = 0f;
                 tapCount = 0;
             }

I come up with this.

You should put this in a script that is attached to the cube.

     public float maxDelay = 0.5f;
     bool touched = false;
     float touchTime;
 
     void OnMouseDown()  // This is called when the cube is clicked or touched
     {
         if (!touched)
         {
             touched = true;
             touchTime = Time.time;
             StartCoroutine(WaitForDoubleTap());
         }
         else
         {
             touched = false;
         }
     }

     
     System.Collections.IEnumerator WaitForDoubleTap()
     {
         yield return new WaitUntil(() => !touched || Time.time >= touchTime + maxDelay);
         if (Time.time >= touchTime + maxDelay)
         {
             yield break;
         }
         // Do something here...
     }

You can change the “maxDelay” value, it is the maximum time span from one tap to the next.

Good luck!