# How to play the animation, before switching to next car?

**URL:** https://phaser.discourse.group/t/how-to-play-the-animation-before-switching-to-next-car/14024
**Category:** Phaser 3
**Created:** [February 23, 2024, 11:35am UTC](https://phaser.discourse.group/t/how-to-play-the-animation-before-switching-to-next-car/14024 "2024-02-23T11:35:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jasonracingcar](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@jasonracingcar](https://phaser.discourse.group/u/jasonracingcar)
#### Post date: [February 23, 2024, 11:35am UTC](https://phaser.discourse.group/t/how-to-play-the-animation-before-switching-to-next-car/14024/1 "2024-02-23T11:35:52Z")

</div>

I have an array of 10 cars.  
The current car represented by  
`let currentCarIndex = 0;`  
`let currentCar = cars[currentCarIndex]; `  
and to get next car I increment the `currentCarIndex` by 1.  
When the current car crashes, play the animation.

` currentCar.play("crush");`  
`currentCarIndex++;`  
`currentCar = cars[currentCarIndex]; `

But it doesn’t play the animation. It switches to next car immediately.

How to make it play the animation, and the switch to the next car ?

---

<div class="post-metadata">

### Author: ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)
#### Post date: [February 23, 2024, 4:56pm UTC](https://phaser.discourse.group/t/how-to-play-the-animation-before-switching-to-next-car/14024/2 "2024-02-23T16:56:11Z")

</div>

Use the animation complete event maybe.

---

<div class="post-metadata">

### Author: ![jasonracingcar](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@jasonracingcar](https://phaser.discourse.group/u/jasonracingcar)
#### Post date: [March 7, 2024, 2:15pm UTC](https://phaser.discourse.group/t/how-to-play-the-animation-before-switching-to-next-car/14024/3 "2024-03-07T14:15:46Z")

</div>

didn’t help.

---

<div class="post-metadata">

### Author: ![pyf](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/pyf/32/7754_2.png) [@pyf](https://phaser.discourse.group/u/pyf)
#### Post date: [March 8, 2024, 2:19am UTC](https://phaser.discourse.group/t/how-to-play-the-animation-before-switching-to-next-car/14024/4 "2024-03-08T02:19:53Z")

</div>

try  
xxx.anims.play(“yyy”)
