# Tween not working in collision

**URL:** <https://phaser.discourse.group/t/tween-not-working-in-collision/2239>\
**Category:** Phaser 3\
**Created:** [April 24, 2019, 5:49pm UTC](https://phaser.discourse.group/t/tween-not-working-in-collision/2239 "2019-04-24T17:49:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![espace](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/espace/32/1405_2.png) [@espace](https://phaser.discourse.group/u/espace)\
**Post date:** [April 24, 2019, 5:49pm UTC](https://phaser.discourse.group/t/tween-not-working-in-collision/2239/1 "2019-04-24T17:49:52Z")

</div>

hi,

i’m want to make a tween on my enemy when a bullet collide with him, but i have an error with the tweens, ‘this’ is not good interpretated. How could i do to fix it ? thanks for your reply.

```
   bullets = g.physics.add.group({
    		defaultKey: 'particles',
    		maxSize: 10
    });

    // in update
    this.physics.add.collider(enemys,bullets,on_hit,null,this)

    on_hit=(enemy,bullet)=>{
      //this works
      bullet.visible=false;

      //this not works
      this.tweens.add({
    	    targets: enemy,
    	    duration: 200,
    	    ease: 'Linear',
    	    scaleX : 2,
    	    scaleY : 2,
    	    yoyo: true,
    	    onComplete:()=>{enemy.flag=false}
       })
    }
```

---

<div class="post-metadata">

**Author:** ![jjcapellan](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jjcapellan/32/542_2.png) [@jjcapellan](https://phaser.discourse.group/u/jjcapellan)\
**Post date:** [April 24, 2019, 7:53pm UTC](https://phaser.discourse.group/t/tween-not-working-in-collision/2239/2 "2019-04-24T19:53:54Z")

</div>

Hi @espace,  
You can get the scene object from enemy or bullet. Try something like this:

```javascript
enemy.scene.tweens.add({
    	    targets: enemy,
    	    duration: 200,
    	    ease: 'Linear',
    	    scaleX : 2,
    	    scaleY : 2,
    	    yoyo: true,
    	    onComplete:()=>{enemy.flag=false}
       });

```

In arrow functions “this” works in a different way.  
Regards.

---

<div class="post-metadata">

**Author:** ![espace](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/espace/32/1405_2.png) [@espace](https://phaser.discourse.group/u/espace)\
**Post date:** [April 25, 2019, 5:22am UTC](https://phaser.discourse.group/t/tween-not-working-in-collision/2239/3 "2019-04-25T05:22:33Z")

</div>

Hi jjcapellan, thanks. Is it proper to phaser 3 this trick ? i didn’t know before…

---

<div class="post-metadata">

**Author:** ![jjcapellan](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jjcapellan/32/542_2.png) [@jjcapellan](https://phaser.discourse.group/u/jjcapellan)\
**Post date:** [April 25, 2019, 8:57am UTC](https://phaser.discourse.group/t/tween-not-working-in-collision/2239/4 "2019-04-25T08:57:28Z")

</div>

Hi,

> [@espace](#):
>
> it proper to phaser 3 this trick ? i didn’t know before…

I don’t know if it is the best way. This is javascript, there are always a thousand ways to do something, and for someone who comes from java or c ++ is crazy 😀.  
In this case, if you don’t want to introduce “tricks” in your code, you can replace the arrow function with a “traditional” one. It isn’t so cool but in this case it will work as expected 😀.  
Regards.
