Tiles created separately with Tile API are a bit disconnetted

Feniso

  • Posts: 8
Since you can't edit at runtime the tiles added in the scene editor, the only way it's to add all the tiles during runtime if you want to edit them. The problem is that sometimes the collision shapes of the tiles get a bit disconnected, so if a body is sliding over a row of tiles (like a player running over them) it get stuck (if the collision shape is a rectangle) or it jump a little forward (if the corners of the rectangle have been cut, making the collision shape an octagon). It happens at random, and when it gets stuck you just have to go a bit backward and then forward again and it will pass, so I'm sure it's a bug.

Hectate

  • *
  • Posts: 4645
It is not a bug; it's an artifact of how Box2D resolves collisions. It cannot be 100% perfectly solved if you are placing tiles at runtime, unfortunately. The very reason you have to place all tiles at runtime is because Scene Designer tiles are combined into a single shape to reduce the number of shapes and potentially inappropriate collisions like this. People have had luck by "beveling" the corners of their actors, or using round shapes (to avoid corner/corner collisions).

Quote from: box2d manual
In many cases a game environment is constructed by connect several edge shapes end-to-end. This can give rise to an unexpected artifact when a polygon slides along the chain of edges. In the figure below we see a box colliding with an internal vertex. These ghost collisions are caused when the polygon collides with an internal vertex generating an internal collision normal.



If edge1 did not exist this collision would seem fine. With edge1 present, the internal collision seems like a bug. But normally when Box2D collides two shapes, it views them in isolation.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Feniso

  • Posts: 8
Oh, thank you! Sorry I didn't reply to you earlier, I just didn't think someone would have replied to me so fast. May I question you just one more thing? I've found out that if you set a tile twice in the same and then you remove it, the collision shape persist. I was going to report this as a bug, but after reading your explanation I'm afraid it could be just how the Tile API works. Should I report this as a bug?

Hectate

  • *
  • Posts: 4645
If you're saying that you can place a tile in the same layer at the same coordinates twice in a row, and then remove the tile (on that layer at those coordinates); but a collision shape is left behind - then yes that is a bug. If that's happening it sounds like adding a tile to a location (without manually removing it first) fails to completely remove the old tile.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.