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)
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:
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. 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.
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.