Page 1 of 1

Getting stuck between adjacent objects

Posted: Thu Jul 04, 2019 6:09 am
by iHussar
Hello, newbie here.

I'm making a simple platformer game using love.physics for all the physics. I have a map where the platforms are made by many 32x32 blocks put together in order to create a perfect, bigger platform (with no separation or differences between the blocks).
However, rarely (not so rarely) my player get stuck right where two blocks meet.

Any ideas for handling this?

Thanks!

Re: Getting stuck between adjacent objects

Posted: Fri Jul 05, 2019 12:54 pm
by tahoma
It must have something to do with the way you handle collisions. It might make sense to copypaste the corresponding code here.

Re: Getting stuck between adjacent objects

Posted: Fri Jul 05, 2019 1:28 pm
by TheHUG
General advice for platformers is to avoid using physics engines, (i've specifically heard people say not to use box2d in fact, which is what love.physics uses behind the scenes.

You are probably best off just using bounding-boxes or even tile-based collisions.

If you prefer to use love.physics (if you're doing this in part to familiarize yourself with it for example), give us some code so we can help find the issue.

Re: Getting stuck between adjacent objects

Posted: Fri Jul 05, 2019 3:57 pm
by iHussar
Thank you for the replies! I did some research and I found out that is better to treat a long platform as just one big collision box. Actually I had tought about this but now I realize that you can do this much more easily with Tiled ;)

Re: Getting stuck between adjacent objects

Posted: Fri Jul 05, 2019 3:59 pm
by pgimeno
This is a common issue, and not easy to fix. I've experienced it even in famous commercial games such as Need for Speed Most Wanted in PS2: you are running in contact with a wall, and suddenly you collide with something that is not there, but only sometimes: you go back a bit, try to hit that invisible wall again and this time it goes through without problems.

TheHUG's advice is sound, but avoiding this specific issue is a pain. Bump tries to avoid it by checking collisions with the closest box first. It usually works, but it doesn't always succeed.

This blog mentions Bump's solution: https://hopefultoad.blogspot.com/2017/0 ... ponse.html

In this other blog the approach is different, and it sounds more general to me: http://metareal.net/blog/?p=69 (see "Snagging on seams").

EDIT: Or just what you said! :nyu: