# Checking "if collided"

**URL:** <https://phaser.discourse.group/t/checking-if-collided/4256>\
**Category:** Phaser 3\
**Created:** [November 14, 2019, 1:32pm UTC](https://phaser.discourse.group/t/checking-if-collided/4256 "2019-11-14T13:32:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ross\_Evan](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/ross_evan/32/1142_2.png) [@Ross\_Evan](https://phaser.discourse.group/u/Ross_Evan)\
**Post date:** [November 14, 2019, 1:32pm UTC](https://phaser.discourse.group/t/checking-if-collided/4256/1 "2019-11-14T13:32:29Z")

</div>

I want to implement a part of my game where if the player stands on a hitbox area, he is able to use a special item. I have "this.physics.add.collider(); and the same with overlap, but I’m looking for something I can put in update, to check IF currently colliding or overlapping. Something like “isColliding” but how do I tell it what it is colliding WITH?

---

<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:** [November 14, 2019, 9:52pm UTC](https://phaser.discourse.group/t/checking-if-collided/4256/2 "2019-11-14T21:52:52Z")

</div>

Physics bodies store their current collision state (in `blocked`, `touching`) but not which bodies they’re colliding with.

You would have to store that state yourself (in a variable, property, or `player.data`) in the collider/overlap callback, read it in update(), then reset it at the end of update().

---

<div class="post-metadata">

**Author:** ![Ross\_Evan](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/ross_evan/32/1142_2.png) [@Ross\_Evan](https://phaser.discourse.group/u/Ross_Evan)\
**Post date:** [November 14, 2019, 10:04pm UTC](https://phaser.discourse.group/t/checking-if-collided/4256/3 "2019-11-14T22:04:22Z")

</div>

Could you show me an example of this please?

---

<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:** [November 15, 2019, 12:18am UTC](https://phaser.discourse.group/t/checking-if-collided/4256/4 "2019-11-15T00:18:41Z")

</div>

[https://codepen.io/samme/pen/pooxMJW?editors=0010](https://codepen.io/samme/pen/pooxMJW?editors=0010)

---

<div class="post-metadata">

**Author:** ![Ross\_Evan](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/ross_evan/32/1142_2.png) [@Ross\_Evan](https://phaser.discourse.group/u/Ross_Evan)\
**Post date:** [November 15, 2019, 3:18pm UTC](https://phaser.discourse.group/t/checking-if-collided/4256/5 "2019-11-15T15:18:14Z")

</div>

Thank you Samme for the help and quick response! One thing I noticed about overlap, is that my player seems to just fall right thru the floor tile when overlapping. I’m not sure why this is happening, or how I can fix it. I’m using arcade physics.

---

<div class="post-metadata">

**Author:** ![seyuup](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@seyuup](https://phaser.discourse.group/u/seyuup)\
**Post date:** [November 15, 2019, 11:33pm UTC](https://phaser.discourse.group/t/checking-if-collided/4256/6 "2019-11-15T23:33:14Z")

</div>

Is the floor your player is falling through a Sprite or a tile?

You can use:  
scene.physics.overlap(GameObject1, GameObject2, callback, preProcessCallback, callbackContext)

This will return **true** if there is a collision, and **false** if there is not a collision.  
[https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.ArcadePhysics.html#collide](https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.ArcadePhysics.html#collide)
