Actor in platformer runs into disappearing invisible walls

terblus

  • Posts: 205
I have an actor moving along a straight line above tiles. Very frequently it will hit an invisible wall and stop moving forward. If I move it back and then forward again it will be able to walk past the point where the invisible wall was. Shortly after this it will hit another invisible wall and the process repeats itself. Why is this happening? The actor is walking on tiles that were created at runtime. I suspect the problem is related to this because I only noticed it after I added those tiles. This is the actor the player has control over, by the way.

« Last Edit: August 08, 2011, 03:05:15 pm by terblus »

terblus

  • Posts: 205
I have made some more observations on this problem. First, I have confirmed that this problem only happens when I use tiles created at runtime. Second, collisions with invisible walls seem to happen at the border between tiles. Third, all actors run into these walls, not just player actors.

Hectate

  • *
  • Posts: 4643
The issue is most likely that Box2D is detecting the borders and "catching" corners on each other. One solution is to "round" the corners of your actor's collision shapes using the polygon tool instead of just boxes. That would allow the collisions to slide over each other easily.

Normally, tiles are combined into a single shape, so a row of tiles will have a solid line as their surface collision shape - but runtime tiles are not combined and that means there's lots of corners in that row.

This is a similar issue to the problem of actors not fitting into a gap that is their exact measurement in height/width - corners are catching.
:
:
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.

terblus

  • Posts: 205
I have rounded the corner of my player and now instead of running into invisible walls the actor will occasionally "hop" over invisible bumps. Is there any way to avoid this? Keep in mind this actor is quite small, 16x16, so there is not a ton of room for rounding.

coleislazy

  • *
  • Posts: 2607
You may be able to create a terrain region over the tiles. I'm not sure how to do this at runtime, though. I've never tried. But it should get around the bug in Box2D.

terblus

  • Posts: 205
Thanks for the suggestion. This would only be useful to me though if I could alter this size of the region, and I don't think there's any way to dynamically alter a terrain region. Does anyone know a way? Or is there some other way I could get around this corner catching problem?

coleislazy

  • *
  • Posts: 2607
You'd have to do it with code, probably. I can try it out tomorrow at work (I'm at my second job now and don't have SW).