# Selecting correct physics (engine)

**URL:** <https://phaser.discourse.group/t/selecting-correct-physics-engine/4387>\
**Category:** Phaser 3\
**Created:** [November 27, 2019, 9:27pm UTC](https://phaser.discourse.group/t/selecting-correct-physics-engine/4387 "2019-11-27T21:27:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fselcukcan](https://avatars.discourse-cdn.com/v4/letter/f/b5a626/32.png) [@fselcukcan](https://phaser.discourse.group/u/fselcukcan)\
**Post date:** [November 27, 2019, 9:27pm UTC](https://phaser.discourse.group/t/selecting-correct-physics-engine/4387/1 "2019-11-27T21:27:16Z")

</div>

How to determine which Phaser physics engine for a certain project?

What are the key differences of three physics engine **arcade** , **impact** , **matter** coming with Phaser 3?

Also when do I not need to use one?

Currently, I want to build [something like this](http://www.85play.com/skill-games/30713/ugly-invasion.html) and simulate the same kind of physical interaction. Which one should I select? Note there are circular objects touching each other, colliding.

---

<div class="post-metadata">

**Author:** ![Telinc1](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/telinc1/32/60_2.png) [@Telinc1](https://phaser.discourse.group/u/Telinc1)\
**Post date:** [November 28, 2019, 8:07am UTC](https://phaser.discourse.group/t/selecting-correct-physics-engine/4387/2 "2019-11-28T08:07:42Z")

</div>

Arcade is fast and easy to use. However, it only supports rectangular bodies (more specifically, axis-aligned, or non-rotated rectangles) and circular bodies out of the box. If you can get away with with just those shapes, Arcade is probably the best option to start with. Note that it supports custom collision callbacks, so you can technically implement other shapes yourself.

I’m less familiar with Impact, but as far as I’ve seen, it’s similar to Arcade, but it supports slopes in tilemap collisions. I haven’t encountered a another good use case for it yet.

Matter is a full-featured physics engine. It supports practically any shape for a body, it allows you to chain bodies together and make them interact in different ways. It’s slightly slower and harder to use, especially compared to Arcade, but I’d recommend it if you need complex physics.

The examples on the Phaser website can show you how each physics system works and what it supports. I can’t check the game you linked right now, but if it only has circular bodies, you might as well go for Arcade. Otherwise, you should turn to Matter.

---

<div class="post-metadata">

**Author:** ![fselcukcan](https://avatars.discourse-cdn.com/v4/letter/f/b5a626/32.png) [@fselcukcan](https://phaser.discourse.group/u/fselcukcan)\
**Post date:** [November 28, 2019, 9:41am UTC](https://phaser.discourse.group/t/selecting-correct-physics-engine/4387/3 "2019-11-28T09:41:55Z")

</div>

Thank you very much for the detailed clear explanation.

I will only need circular bodies colliding with each other and some rectangular walls in addition to the world bounds.

Currently I do not know how to create a circular body though. Maybe I should ask in another question for forum granularity. I use a transparent background png with a basketball on it with arcade but they collide as if the whole rectangular png file is the object colliding. I will look into that and examples.

---

<div class="post-metadata">

**Author:** ![Telinc1](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/telinc1/32/60_2.png) [@Telinc1](https://phaser.discourse.group/u/Telinc1)\
**Post date:** [November 28, 2019, 10:14am UTC](https://phaser.discourse.group/t/selecting-correct-physics-engine/4387/4 "2019-11-28T10:14:06Z")

</div>

> [@fselcukcan](#):
>
> Currently I do not know how to create a circular body though.

Bodies are rectangles by the default. You should explicitly set your body to be a circle with the [`setCircle` method](http://labs.phaser.io/edit.html?src=src%5Cphysics%5Carcade%5Ccircular%20body.js), which is available both on the Body itself and on Arcade Sprite and Images.

---

<div class="post-metadata">

**Author:** ![fselcukcan](https://avatars.discourse-cdn.com/v4/letter/f/b5a626/32.png) [@fselcukcan](https://phaser.discourse.group/u/fselcukcan)\
**Post date:** [November 28, 2019, 12:54pm UTC](https://phaser.discourse.group/t/selecting-correct-physics-engine/4387/5 "2019-11-28T12:54:43Z")

</div>

I have looked into `setCircle()` and it works. However, when the balls reach the bottom and interact with the other balls resting there they start to shake and move weirdly. E.g.: They may change position with each other instantly etc. Here is the fiddle: [https://jsfiddle.net/fselcukcan/ovy9c4bm/7/](https://jsfiddle.net/fselcukcan/ovy9c4bm/7/).

Example works like that: You click pointer and hold to create a ball. And release pointer to release the ball fall under gravity, or it is released after reaching maximum scale. You can drag around while blowing.

What is the reason for that? What am I missing? Am I using a wrong `collider` logic to make balls collide between each other? Or am I setting the circle radius wrong/bad value? Do I need to add mass to them?

How can I prevent this unstable kind of view?

---

<div class="post-metadata">

**Author:** ![fselcukcan](https://avatars.discourse-cdn.com/v4/letter/f/b5a626/32.png) [@fselcukcan](https://phaser.discourse.group/u/fselcukcan)\
**Post date:** [November 28, 2019, 1:03pm UTC](https://phaser.discourse.group/t/selecting-correct-physics-engine/4387/6 "2019-11-28T13:03:09Z")

</div>

> [@Telinc1](#):
>
> Note that it supports custom collision callbacks, so you can technically implement other shapes yourself.

I did not understand how it supporting the custom collision callbacks enables me to implement other shapes myself. Can you explain this?

---

<div class="post-metadata">

**Author:** ![Telinc1](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/telinc1/32/60_2.png) [@Telinc1](https://phaser.discourse.group/u/Telinc1)\
**Post date:** [November 28, 2019, 7:25pm UTC](https://phaser.discourse.group/t/selecting-correct-physics-engine/4387/7 "2019-11-28T19:25:51Z")

</div>

> [@fselcukcan](#):
>
> However, when the balls reach the bottom and interact with the other balls resting there they start to shake and move weirdly.

I haven’t really used circle bodies in the past, so I’m not sure what the reason for that is. It could easily be a bug with Arcade.

> [@fselcukcan](#):
>
> I did not understand how it supporting the custom collision callbacks enables me to implement other shapes myself. Can you explain this?

When you check for collision or add a collider, one of the parameters you can pass is a callback which allows you to perform additional processing on the collision. If you update the values that Arcade needs (`overlapX`, `overlapY`, and the `touching` flags), you can essentially customize the way collision is detected. You could combine this feature with a library like SAT.js to support polygonal bodies.
