Selecting correct physics (engine)

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 and simulate the same kind of physical interaction. Which one should I select? Note there are circular objects touching each other, colliding.

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.

1 Like

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.

Bodies are rectangles by the default. You should explicitly set your body to be a circle with the setCircle method, which is available both on the Body itself and on Arcade Sprite and Images.

1 Like

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/.

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?

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

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.

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.