Problems with the Collision Mask

Hey all,

I have a problem with the Collision mask of my Player and other Plattformobjects.

Sometimes when I jump on an object this happens:

collosionmask1

The Player seems to fly and sometimes it also works like a step and I can reach objects which are normally to high for a normal jump…

These are the Collision Masks:


collosionmask3

After sketching the objects in Piskel I also crop the sprites.

I hope someone has an idea?

kater

1 Like

I don’t know if there’s a different way to fix this, but I always see people using colision box with rectangles and I believe it’s to avoid this kind of thing. Platform example:

I particularly prefer to make the collision boxes a little smaller than the images. The actions sometimes happen very fast and having very accurate collision boxes can sometimes give the impression that the objects have not touched each other

Maybe the platform example can help you. Check it out :wink:

Hi Rasterisko,

thanks for your reply - I tried it and used the hitbox exactly as in the platform example and even made it a lot smaller but the problem stays the same… :confused:

Do you changed the colision box on barrel too?

Hello,
Where are the origin points of the sprites placed?
It looks like the barrel one is on the top left, when it should be on the top and middle. Theory has to be checked anyway.
Alexandre

Yes. Actually I am really surprised and I have absolutely no idea how this could happen:

collosionmask

The Barrel is not a platform anymore, I put the hitbox in front of it, so you can see it. And another hitbox behind the Player - the red one. I walked the Player/hitbox again to the edge and the hitbox fell down, the Player not.

These are my events:

I also tried to delete the Behavior of the Player “Platform Charakter” but then he doesn’t move anymore… Maybe there is the problem???

Okay, I am quite sure now that the problem is that I didn’t delete the Behavior of my Player “Platform Charakter” but I don’t see the bug why he isn’t moving with the hitbox… (the hitbox moves and jumps, the Player stays on his position, making the animation for running without moving forward)

You are only changing the position of your player once at the start of the scene. After that, the action won’t trigger again. Move the player set position action to an unconditional event.

And I don’t see how using a rectangular collision box will help. You’ll have a collision box that’s not as accurate as you had before. You should be able to use the hitbox of the player.

So, getting back to your original problem. Does the charater have more than 1 animation frame? If so, is the redefined collision mask applied to all frames?

@kater I’m sorry make you did all the changes for nothing. I thought something like this was going on here.

That’s why I thought that rectangle box collision could help. But looking better your character is quite far away.

Is the barrel on another layer that your camera isn’t tracking (or tracking at another speed)?

1 Like

Another thing you can do to see what’s happening is to turn on debugging view (of bounding boxes). This will show all the boundaries and collision boxes for all objects, and may give a hint to what is happening :

2 Likes

Hi MrMen!

Thanks for your advices. The charakter has more than 1 animation frame but its edited for all of them - I just looked it up.

The debugging tool is really interesting! This is how it looks (I made the collision mask of the barrel even more smaller than before):

debugging1

debugging2

So,it looks like the blue frame of my charakter sticks so the red frame/the collision mask of the barrel but ignores the blue frame of the barrel? I’m not sure how to interpret that.

@Rasterisko its alright, I am very happy for all of your help here, trying to find a solution for my problem… and besides I am learning a lot! :slightly_smiling_face: (Both objects are on the Base Layer)

1 Like

The blue frame is the outline of the sprite. It shouldn’t have any input to the collision.

What behaviours do you have attached to the sprites? Platformer? Physics2?

How are you moving the player?

My Player has the behavior “Platform Object” (and Flickering but only when it gets hit by enemies), the option “can grab platform ledges” is not activated. And the Barrel has the behavior “Platform”. The option “ledges can be grabbed” is also not activated.

This is how I move my Player:

I was able to reproduce the problem without difficulties. :thinking:

Colision

Player has not marked the option “Can grab platform ledges” and the object with platform has not marked the option “Ledges can be grabbed” like you did, Kater.

Looks like the collision mask is “completing” the box. Something like this:

Colision edited

1 Like

Oh, really good idea to try it on another platformer! And really interesting. So I just have to accept it I guess? :woman_shrugging: …or try it with another “extra” collision box again as you told me before @Rasterisko.

I can’t confirm it’s a bug. I think someone of Gdevelop Team need look this.

That looks like a bug, GDevelop has two types of collisions: the AABB, which is just the top & bottom left and right positions, for quickly seeing if the object is touching another one without doing a full collisions check which is much longer to execute, and the actual one which used complex maths and the hitboxes. While GDevelop should begin with an AABB check to quickly exclude far away platform from collisions checks, it shouldn’t stop here and do an actual collision check.

You can submit a bug report at https://GitHub.com/4ian/GDevelop/issues/new :wink:

3 Likes

I sent the example on github and 4ian said it’s not a bug. It’s a limitation of platform character behavior (Custom hitboxes are indeed not supported by the platformer object behavior - only the rectangle surrounding the red polygons will be used.). And concave polygon is not suported on game engine, so my example wouldn’t work, even for another behavior. He explained what’s going on here: Collision mask is not being considered exactly as it was made · Issue #3344 · 4ian/GDevelop (github.com)

@kater, I think the only solution will be use a rectangular collision box for your character and make the different collision box just for your platforms (like the barrel). And never use a concave shape for the colision.

2 Likes

Thank you @Rasterisko!! :raised_hands:

I am really happy to know now whats going on.

1 Like

Your example is incorrect. If you look at the collision box in the editor, you’ll see the warning that the polygon is not convex. GDevelop then defaults to the full image collision box.

Sorry, I didn’t see your response later on. Ignore my comment.