1
\$\begingroup\$

I develop games for my own pleasure and also to share experiences with my kids learning coding.

Lately I have been working on a classic retro platform game using XNA and Farseer.

One issue I am having is that my characters sometimes get stuck while walking on tiles. These tiles are blocks put next to each other. It seems that sometimes when reaching the edge of the next tile, character get stuck.

I have read several solutions over the internet:

  • Make a weldjoint - did not fix my issue
  • Use an edgeshape - haven't found out how to do this yet
  • Make one big shape out of my several tiles (the background floor for example) - haven't found out how to do this yet

A video can be seen here. You'll see that I have sometime to jump in order to be able to move on, otherwise I simply get stuck. I also commented and shared my sources here.

For now, as a nasty trick, I create circle bodies rather than rectangles. It does reduce the issue but not completely and I feel this is an ugly workaround anyway.

Would any one be so kind as to point me in the right direction or provide me an example? I write in VB.NET but can adapt a C# example if needed.

\$\endgroup\$
1
\$\begingroup\$

Answering myself, I finally decided to review the way I generate my tiles.

When I detect a continuous serie of tiles, i'll generate one big rectangle rather than a serie of small rectangles. It requires a bit of gymnastic but not that much and it pays off : my characted no longer get stuck on edge.

I would rather have used edgeshapes but dont have the skills yet.

A video of the result can be seen here : http://labalec.fr/erwan/?p=754 .

\$\endgroup\$
0
\$\begingroup\$

Depending on the system you use, you could tweak your collision detection to allow a small amount of leeway on corners. This could even be useful for making stairs, with your stair height being slightly less than your leeway.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.