# Test intersection of two game objects (Phaser 3)

**URL:** <https://phaser.discourse.group/t/test-intersection-of-two-game-objects-phaser-3/8021>\
**Category:** Examples\
**Created:** [November 4, 2020, 9:18am UTC](https://phaser.discourse.group/t/test-intersection-of-two-game-objects-phaser-3/8021 "2020-11-04T09:18:17Z")\
**Posts on this page:** 2\
**Page:** 1

<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 4, 2020, 9:18am UTC](https://phaser.discourse.group/t/test-intersection-of-two-game-objects-phaser-3/8021/1 "2020-11-04T09:18:17Z")

</div>

https://codepen.io/samme/embed/preview/QWErXxP?default-tabs=js%2Cresult&height=300&host=https%3A%2F%2Fcodepen.io&slug-hash=QWErXxP

https://codepen.io/samme/embed/preview/mdpwvwK?default-tabs=js%2Cresult&height=300&host=https%3A%2F%2Fcodepen.io&slug-hash=mdpwvwK

You can do this without physics. You copy the bounds of the game objects to rectangles and then use the [Phaser.Geom.Intersects](https://photonstorm.github.io/phaser3-docs/Phaser.Geom.Intersects.html) methods. Recycling the rectangles is efficient.

Most game objects have two boundaries, possibly distinct: [Phaser.GameObjects.Components.GetBounds#getBounds()](https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Components.GetBounds.html#getBounds) and [Phaser.Display.Bounds.GetBounds()](https://photonstorm.github.io/phaser3-docs/Phaser.Display.Bounds.html#.GetBounds). If you’re not interested in transforms then `GetBounds()` is faster.

[Phaser.Geom.Intersects.RectangleToRectangle()](https://photonstorm.github.io/phaser3-docs/Phaser.Geom.Intersects.html#.RectangleToRectangle) tells you whether the rectangles intersect at all, and [Phaser.Geom.Intersects.GetRectangleIntersection()](https://photonstorm.github.io/phaser3-docs/Phaser.Geom.Intersects.html#.GetRectangleIntersection) calculates the intersection area, if any.

---

<div class="post-metadata">

**Author:** ![Benstrocity](https://avatars.discourse-cdn.com/v4/letter/b/a4c791/32.png) [@Benstrocity](https://phaser.discourse.group/u/Benstrocity)\
**Post date:** [November 13, 2020, 2:24pm UTC](https://phaser.discourse.group/t/test-intersection-of-two-game-objects-phaser-3/8021/2 "2020-11-13T14:24:04Z")

</div>

@samme you are a genius man. I hope you know that. Half of my game is only functional because of some of the posts you’ve been involved in.
