Weird behavior with platformer hitting walls

Hi.

I am experimenting the platformer example default scripts for hero, and I have also added a tile map with editor generated collision objects.
What happens is that I added a wall of tiles and jumping beside the wall sometimes makes hiro stop the jumping animation and starting the ground_contact behavior. I think it happens because one of the contact points of the collision points up (while the two other ones point in the normal of the wall). Something similar to this image, but with another contact point whose normal points upwards.


Do you have any suggestions for making this jump beside the wall going smooth, I mean, without triggering the ground_contact behavior in the middle of the jump?

Thanks in advance, the engine is really a masterpiece. (I love eclipse plugins architecture, as well as Lua scripts)

Hmm, are all of the pieces of the wall aligned perfectly horizontally and vertically? No gaps in any way?

Hi britzl,

it is a good point, but indeed, they are aligned and there’s no gap among them.

An easy way to repeat this problem is to start the platformer sample project from defold and then try to stack some of the platforms together. It might look like this:


Then, try to jump towards the stacked platforms. You will see that hiro starts to walk as if it was on some of the platforms, like in the screenshot.

Thanks for checking this out.

Kind regards,
Daniel

I’m away doing an internal Defold training all day, but I’ll take a look tonight. Or maybe @Mathias_Westerdahl has some input? He did some investigation regarding collision objects and slopes a while back.

I don’t have anything really insightful here I’m afraid.
First, if the boxes are not truly aligned (position.x and size.width) I would expect this behaviour.
Second, if they are aligned, then I believe it simply might be the fact that Box2D does not collapse the collision points. This is a common problem in all physics engines, and they do various things to solve this (e.g. merging geometry).
I don’t know Box2D enough to suggest a good solution for this. Ping @Ragnar_Svensson, do you have any good ideas?

No good ideas. :frowning: You are basically in the hands of the physics engine in this case. This is also why our custom collision shapes for tile maps do so much (varyingly successful) merging of adjacent tiles, to handle this same issue. In this specific case, I would recommend going for a heuristic that tries to filter out “unwanted” contact points. E.g. only consider ground support when there is a more centered, or possibly several, contact points. This depends a lot on what situations will happen in your specific case, so it’s hard to give a generic solution, but one case to think about is when the avatar moves over an edge and when that will be defined as a fall and not.

1 Like

When I worked with Stencyl, in order to check a ground collision, I checked the position of the contact point compared with the position of the player character. That way you can see if the player character is above the shape that he is colliding with.

I see, there should be some customization on the script to handle these corner cases and some more insight on Box2D. I hope I’ll get some time to dig into it and give some feedback to you. Thanks for all the good points.

1 Like

Hi @danielbaggio, 4 years later I encounter the same problem.

Did you find a solution?
Thanks
Boris

One solution is to not rely purely on the collision contact points but also on raycasts to determine if it is a wall or ground collision.

Another is to change from a box shape to a sphere shape as that should eliminate most (all?) such problems as in your video.

Thanks Björn for this quick reply!