What is the best way to make a complex collision mask

Hello,

I have two questions:

What is the best way to make a complex collision mask like this:

This is mine, but it’s not working:

My other question:
Is there any behavior for moving the object up and down or left to write?

thanks,

Hey there,
For th first one, the engine does not support “concave” shapes. You would have to split such a complex object into multiple objects.
From Cuemath:

For the second one, it seems the Top-Down movement behaviour could work. Or is there something specific you wanted to do?

I’m guessing this is to check a room or area. It looks like the bottom right mask is concave (it has a notch)
This type of mask should be used sparingly and there could be a more efficient way. IDK.

I would use as few as masks as possible and try to use mostly squares and rectangles. They’re much easier to test for. Something like. It’s a bit like a puzzle.

Thanks.
But how should I fill out this part:

Rectangle? polygon? edge?
And how about size?

I didn’t realize it was physics. That uses it’s own mask. You use an image for alignment. I believe the polygon can only be 1 convex polygon unlike the basic mask.

https://wiki.gdevelop.io/gdevelop5/behaviors/physics2/#body-shape

1 Like

I suppose there is a misunderstanding.
This is a simple rectangle that has physics behavior.
I think the link you provided doesn’t suit what I have in mind.

Do you mean this part:

If yes, I should select the rectangle or polygon?

Here is the result by the method you are saying.
The issue is the yellow circle disappears at the beginning!

I don’t know what you’re trying to do. You won’t be able to make 1 solid mask with the physics behavior. It only does simple masks. What exactly are you trying to do? For physics, the part that is masked is the solid part.

This is just a slower example of setting it up that I recorded.

This is because physics collisions doesn’t work on the inside of an object (hollow part), so the circle gets pushed out. Look at the 1 pixel line above the shape, you can barely see the circle jump on top of it in the game example you provided.

Instead, I suggest you use 2 simple objects, a square and a right triangle, and fill the blue areas by changing their sizes and angles. The physics would be applied to these objects and not the actual shape. Add a rectangular collision mask to the square and a polygon mask to the triangle. Then you can hide these shapes in the game.

3 Likes

The blue part roles like a room for the action game.

Thanks, a lot. Yes, it works for me.

2 Likes