# More information about "sprite.body.touching"

**URL:** <https://phaser.discourse.group/t/more-information-about-sprite-body-touching/961>\
**Category:** Phaser 3\
**Created:** [January 26, 2019, 11:16pm UTC](https://phaser.discourse.group/t/more-information-about-sprite-body-touching/961 "2019-01-26T23:16:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yannick](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/yannick/32/732_2.png) [@yannick](https://phaser.discourse.group/u/yannick)\
**Post date:** [January 26, 2019, 11:16pm UTC](https://phaser.discourse.group/t/more-information-about-sprite-body-touching/961/1 "2019-01-26T23:16:49Z")

</div>

In [my platformer game](https://github.com/yandeu/phaser3-typescript-platformer-example#phaser-3-typescript-platformer-example) i use `(this.body.blocked.down || this.body.touching.down)` to determine if the player is allowed to jump or not. [[my code on line 69](https://github.com/yandeu/phaser3-typescript-platformer-example/blob/master/src/components/player.ts#L69)]

This works great if the player is on a platform sprite. Unfortunately it allows the player also to jump if he is collecting a coin from above or jumping on a enemy and is pressing the up key at the same time.

`this.body.touching` gives only information about the direction but no information about the body it is touching.

If it would give me some information like this, …

```
{
 none: false,
 down: true,
 left: false
 right: false,
 up: false,
 body:(the sprite it is touching)
}

```

… it would be easy to determine if the player is touching a platform or something else.

It this possible? How would you solve this?

Thanks a lot 🙂

---

<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:** [January 27, 2019, 3:13am UTC](https://phaser.discourse.group/t/more-information-about-sprite-body-touching/961/2 "2019-01-27T03:13:28Z")

</div>

If you use static bodies for platforms then you can test for this with [body.onFloor()](https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Body.html#onFloor__anchor). Or [body.blocked.down](https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Body.html#blocked__anchor) (same). So that’s one way.

If you want to record which bodies are colliding you would probably do that in a collision callback. If you set a flag of some sort, you would reset it at the end of the scene’s `update` method.

---

<div class="post-metadata">

**Author:** ![yannick](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/yannick/32/732_2.png) [@yannick](https://phaser.discourse.group/u/yannick)\
**Post date:** [January 27, 2019, 12:14pm UTC](https://phaser.discourse.group/t/more-information-about-sprite-body-touching/961/3 "2019-01-27T12:14:53Z")

</div>

Thanks @samme .

I did not know that there where 2 type of bodies (Dynamic and Static).

Now I now only use `this.body.bocked.down` for the player.

For the tiles: Instead of switching to a StaticGroup, I have set the second parameter of `physics.add.existing(this, true)` to true, which will create a static body instead of a dynamic body.

Here the updated code for the [Tiles](https://github.com/yandeu/phaser3-typescript-platformer-example/blob/master/src/components/tiles/tilesSingle.ts#L8) and for the [Player](https://github.com/yandeu/phaser3-typescript-platformer-example/blob/master/src/components/player.ts#L68).

Your reply helped a lot 🙂

---

<div class="post-metadata">

**Author:** ![maikthomas](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/maikthomas/32/398_2.png) [@maikthomas](https://phaser.discourse.group/u/maikthomas)\
**Post date:** [March 19, 2019, 6:21pm UTC](https://phaser.discourse.group/t/more-information-about-sprite-body-touching/961/4 "2019-03-19T18:21:43Z")

</div>

I just ran into this post, looks very similar to one I just added 🤦‍♂️  
However although my platforms are static bodies, my objects are also in a staticGroup…  
Is there a way to have an overlap but not return true for onFloor?  
I have an simple repro based on the First Game example on my post [body.onFloor true when overlapping with staticGroup body](https://phaser.discourse.group/t/body-onfloor-true-when-overlapping-with-staticgroup-body/1746)
