I try to make a Match 3 Game as a kind of Hello World project. It is based on a a tutorial video project.
Now I have a simple problem. All comercial games fil their grids with a little “bounce” animation when the pieces (mostly candy stuff) finds its destination place after falling.
The falling is made of Coroutines and works smoothly to the bottom. At the destination field I start a little “bounce” animation clip for each piece. (transform scale and position animation)
Problem: Some animations start to play but most other are not starting. The Debug.Log shows all are starting.
To come closer to the reason I made a simple test. At the End of the Fill Routine I bounce all 81 (9x9 grid) pieces but no piece is animated.
public IEnumerator Fill() {
bool needRefill = true;
while (needRefill) {
for (int y = 0; y < yDim; y++) {
for (int x = 0; x < xDim; x++) {
pieces[x, y].JustMoving = false;
}
}
yield return new WaitForSeconds(fillTime);
while (FillStep()) {
yield return new WaitForSeconds(fillTime);
}
needRefill = ClearAllValidMatches();
}
for (int y = 0; y < yDim; y++) {
for (int x = 0; x < xDim; x++) {
pieces[x, y].JustMoving = false;
pieces[x, y].MovablePieceComponent.BouncePiece();
}
}
}
The BouncePiece which ist called looks like this:
public void BouncePiece() {
bounceCoroutine = BounceCoroutine();
StartCoroutine(bounceCoroutine);
}
private IEnumerator BounceCoroutine() {
if (bounceAnimation ) {
Animator animator = GetComponent<Animator>();
if (animator) {
Debug.Log("Bounce x="+piece.X+" y="+piece.Y);
piece.BounceRunning = true;
animator.Play(bounceAnimation.name);
yield return new WaitForSeconds(bounceAnimation.length);
}
}
}
All Debug for the 81 pieces is shown but only a few animations are started on screen.
What could be wrong?
If animations are starting then only the last ones in the loop.
Thanks for your help.
Michael