Physics 2 - the object collisions are all wrong

I don’t know what I am doing wrong. I set the collisions both for the object and for the character but I keep getting these “invisible walls” and my character don’t follow the outline of the object (the rock pillar).

One workaround is to scale down the position value of the polygons in the behavior of the object, but that is just shooting in the dark - it is nearly impossible to outline the object that way. After all I already outlined it perfectly with the red mask as seen in the screenshot.

The platform behavior might be easier than physics. With collisions you need to set the mask for both player and platforms.

Is the player floating because of the player’s collision mask or the rock’s?

Edit: in your screengrab there are exclamation points before the points. This means the mask is invalid because it’s not convex (?) (I hope I didn’t get that backwards) If it’s invalid I assume it defaults to the boundary box or whatever the default would be.

If I had to guess, I would say the mid-points on the left side of the wall.

1 Like

Nicely spotted. I think it’s because the left edge of the collision mask curves inward (concave :slight_smile: ) - the second to top point appears slightly further right than the other three left edge points. And yes, it defaults to the whole image if there’s a problem.

@firefly09, what does the collision box for your character look like? As @Keith_1357 pointed out with the wall object, make sure there are no exclamation marks with your character’s collision box either.


Oh… I totally did not notice the exclamation marks! Now the collisions are working I guess. But my character is not spawning where it should. I put it above the platform and it’s spawning way above in the air. I can’t see any logic to that.


That only happens with Polygon selected. If i revert back to box, it is all fine.

Check that all the collision boxes (for all the frames) are like this, and not that some are the full image.

What behaviours do you have on your character?

If you turn on debugging, what shapes do you see? With that I mean, add the following event:

Found in actions:

When you run the game, it will be a bit of a mess, but you’ll see the collision boxes.

I see the collision boxes. Nothing out of the ordinary - they are precisely around the objects.
I may be did something, because now my character just passes through the platforms even when both have physics. The moment I change the shape from polygon to box of the player, it is ok. When I use Polygon, nothing works right.
I checked all polygons for all the animation frames - they are the same.
Even when I delete most of my events it’s the same so probably not some event at fault.

You have physics and platformer behaviours on the character and/or the walls? Remove or deactivate one of the behaviours - they can potentially conflict and cause bizarre behaviour.

BTW, the usual collision boxes are not used by the physics behaviour. It uses it’s own collision box.

And I believe the red boxes in that last screen shot are the collision box.

No platformer behaviors. Both Character and Platform are Physics objects. I don’t edit the usual collision boxes - only the ones in the physics properties.

This happens ONLY when using Polygon shapes.

Ok, I missed that from the screen shots. Are you able to replicate this with a small project, with just 2 objects?

Ooook. So the problem comes from the scaling down of the sprites. My character is bigger originally. I scaled it down in the editor. The collision masking points are not taking this into account. I resized all my sprite frames and then it kind of works (still little glitchy).

I find this quite frustrating as I don’t always know the exact sprite size I am gonna need and this calls for constant sprite edits and resizes, otherwise the polygon collision mask is not working properly and takes into an account the original sprite size, instead of the one used in the editor.

This is correct. Physics object collisions do not scale with objects.

This is pretty normal. Generally you should only be putting objects into your scene at their normal form, and it sounds like in this case you might need to do some additional prep on your assets. custom sizes in the scene editor should be used pretty sparingly, because things like Scale X/Y actions will reset them to their original size.

That said, some folks have been looking into the scaling behavior for physics collision masks. No guarantee if/when it will be changed, though: Physics custom hitbox not rescaled · Issue #1812 · 4ian/GDevelop · GitHub

1 Like

How should I use this code?

const SpriteObject = objects[0];
const PhysicsObject = SpriteObject.getBehavior('Physics2');
const Vertices = PhysicsObject.polygon.vertices;

const AdjustedVertices = [];
for(var c of Vertices) {
    // relate position to object scale
    const scaledCoordinates = [


PhysicsObject.polygonOrigin = "Origin";
PhysicsObject.polygon.vertices = AdjustedVertices;