Angled blocks possible with Arcade physics?

I’m working on an Arkanoid type game. There is one bouncing ball that can hit the square bricks using simple Arcade physics.

Now I would like to add simple triangle bricks, where one corner is horizontal/vertical (same as rectangle) and the angled side is a 45 degrees angle, see screenshot.


I know Matter.js can suport these type of collision bodies, but I was wondering if this could be done using just Arcade physics because of performance reasons;

Arcade physics performs better compared to Matter.js on slower devices, especially on slower mobile phones. Plus, most of the collisions will just be simple horizontal/vertical surfaces anyway, so using Matter.js would be overkill so to speak. And as for collision angles, I already figured that when the ball hits the 45 angle surface you can simply flip the X and Y speeds. The game could just have all square bricks, but if this is possible it opens up a lot more variation in the gameplay and levels.

So my questions are;
Is it possible to use a simple triangle collision body in Arcade physics?
Is there a way to change the body behaviour so that it acts like this 90-45-45 triangle?
Would it be possible to use the slopes technique on bricks in a breakout-type game?

Hello @BdR, i think you might wanna check this https://www.codeandweb.com/physicseditor,

Thanks for the link, but I already know how to create a Matter.js polygon body.

I guess my question is;
is it possible to “fake” right-angled triangle bodies using just Arcade Physics?
Or has anyone already tried to create something like this with a workaround?

As far as I know in Phaser 3 with Arcade Physics the collision body can only be rectangular or circular, not a right-angled triangle or polygon. See the code for Phaser.Physics.Arcade.Body, there’s no mention of triangles or polygons there.

I see, yea I just wanted to give an example that I know :blush:
About Arcade, I actually really never checked that :neutral_face:

Arcade physics works only with rectangles and circles but there is a solution. You can provide your own function to check for collision:

this.physics.add.collider(ball, brick, myCustomCheck);

That function will be called only if the ball and the brick collides via their bodies. You can functions from Phaser.Geom.Intersects for more precise collision check.

You may or may not also set customSeparateX and customSeparateY on the body to disable the default separation.