Tilemap collision normals? (DEF-2104)

Hi!

I’m wondering a bit about how the tilemap collision normals is designed to work.
When walking on a flat surface, the normal seems to be the same all the way (pointing upwards).
But, when walking on a 45 degree slope, at the edges, I seem to get normals that are pointing in various directions, making the movement erratic.

Is this as intended? If so, how do I prevent this behavior?

Here is my collision shape (simply using the .png itself) for the two affected tile types (slope 45, and solid ground)

And, here is the result:

2 Likes

It was certainly designed to stitch together all seams perfectly and generate smooth normals under pixel perfect conditions (which seems to be the case in your example). I have been trying to remember what was the case with the slopes, it was >5 years ago iirc. I know there was some difficulties with them along the lines of heuristically deciding how the stitching actually should work, but I can’t remember if we solved it or not. It seems like we didn’t by your example. It could also be the case that there is a limit that some of your cracks is just outside of. Is there uneven normals in every tile crack or just some? I see that we are doing pixelcenter edge detection, and it might be as simple as a 1 vs. sqrt(2) problem.

1 Like

Thought about this some more and I wonder if the case here is that the top-most sloped tile is stitched with the right-vertical edge of the solid ground tile and the lower sloped tile is stitched with the top-horizontal edge of the solid ground. It would explain the look on the normals in the gif.

1 Like

Ok, good to know! I remember you mentioning the stitching to me, but I wasn’t entirely sure if there were any special cases.

Yes, the problem arises at each (slopey) tile edge by the looks of it. The scenario you mention sounds like a possible cause.

Will you add a ticket for this?

Get back to work and do it yourself! Nah, kidding! Created DEF-2104 for you.

5 Likes

To add some more examples, I tested a flatter slope, which exposes the problem a bit more I think.
Here the tiles are at “half height”, i.e. 32x16 pixels, and they match up perfectly pixelwise, but not physics wise. I see two problems. 1, one tile is “thinner” than the other. 2. at the top right corners of the tiles, the slope of the physics becomes flat, making it an uneven surface within the tile.


3 Likes

Resurrecting this to see if anyone has a clean solution to tilemap slopes? Calling @benjames171!