# Playing animations on collision

**URL:** <https://phaser.discourse.group/t/playing-animations-on-collision/9630>\
**Category:** Phaser 3\
**Created:** [May 20, 2021, 8:05am UTC](https://phaser.discourse.group/t/playing-animations-on-collision/9630 "2021-05-20T08:05:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahesh](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@mahesh](https://phaser.discourse.group/u/mahesh)\
**Post date:** [May 20, 2021, 8:05am UTC](https://phaser.discourse.group/t/playing-animations-on-collision/9630/1 "2021-05-20T08:05:55Z")

</div>

Hello everyone,  
I’m new to phaser and having trouble while playing animation when the bullet collides with the enemy. When the collision happens explosion animation does not play.  
code:  
`this.load.spritesheet('explosion', './assets/explosion1.png', { frameWidth: 400, frameHeight: 48 });`  
`this.anims.create({`  
`key: 'explode',`  
`frames: this.anims.generateFrameNumbers('explosion', { start: 0, end: 7 }),` `frameRate: 10,`  
`repeat: -1,`  
`hideOnComplete: true`  
`});`

`this.explosion = new Explosion(this, enemy.x, enemy.y);`

`class Explosion extends Phaser.Physics.Arcade.Sprite{`  
`constructor(scene,x,y){`  
`super(scene,x,y);`  
`scene.add.existing(this);`  
`this.play('explode');`  
` }`  
`}`  
project link: [GitHub - maheshnnaik/Phaser3-project](https://github.com/maheshnnaik/Phaser3-project)  
Thank You

---

<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:** [May 20, 2021, 5:20pm UTC](https://phaser.discourse.group/t/playing-animations-on-collision/9630/2 "2021-05-20T17:20:52Z")

</div>

> [@mahesh](#):
>
> project link: [GitHub - maheshnnaik/Phaser3-project](https://github.com/maheshnnaik/Phaser3-project)

The animation keys don’t match: `explode` vs. `kaboom`.

---

<div class="post-metadata">

**Author:** ![mahesh](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@mahesh](https://phaser.discourse.group/u/mahesh)\
**Post date:** [May 21, 2021, 5:05am UTC](https://phaser.discourse.group/t/playing-animations-on-collision/9630/3 "2021-05-21T05:05:35Z")

</div>

@samme I have updated keys to `explode`, still animation doesn’t play.

---

<div class="post-metadata">

**Author:** ![mahesh](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@mahesh](https://phaser.discourse.group/u/mahesh)\
**Post date:** [May 21, 2021, 5:49am UTC](https://phaser.discourse.group/t/playing-animations-on-collision/9630/4 "2021-05-21T05:49:55Z")

</div>

@samme It worked. I have given the wrong value for `frameHeight` in `preload()`. I changed it from 48 to 400, it worked.
