public void triggerBubbles(Vector2 dest) { //cleans input dest.x = Mathf.Round(dest.x * 10.0f) * 0.1f; dest.y = Mathf.Round(dest.y); int startY = (int)(dest.y + (Mathf.Abs(lowestPoint))); int startX; if (bubbleList[startY].Length == 10) { startX = (int)(dest.x - 0.5f + 5); } else { startX = (int)dest.x + 5; } //must be connected to atleast 3 of the same type Bubble b = bubbleList[startY][startX].GetComponent <Bubble>(); if (b == null) { return; } List <GameObject> bubbles = new List <GameObject>(); bubbles = getSameBubbles(startX, startY, b.getType(), bubbles); //Debug.Log(bubbles.Count); if (bubbles.Count >= 3) { bubbles = new List <GameObject>(); bubbles = getEligibleBubbles(startX, startY, b.getType(), bubbles, false); //Debug.Log(bubbles.Count); //trigger all connections for (int x = 0; x < bubbles.Count; x++) { b = bubbles[x].GetComponent <Bubble>(); if (b == null) { continue; } b.ActiveGravity(); } } }