Getting stuck between adjacent objects

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
iHussar
Prole
Posts: 2
Joined: Thu Jul 04, 2019 5:34 am

Getting stuck between adjacent objects

Post 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!
Attachments
platformer.love
(11.24 KiB) Downloaded 135 times
tahoma
Prole
Posts: 22
Joined: Mon Apr 22, 2019 1:13 am

Re: Getting stuck between adjacent objects

Post by tahoma »

It must have something to do with the way you handle collisions. It might make sense to copypaste the corresponding code here.
TheHUG
Citizen
Posts: 62
Joined: Sun Apr 01, 2018 4:21 pm

Re: Getting stuck between adjacent objects

Post 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.
iHussar
Prole
Posts: 2
Joined: Thu Jul 04, 2019 5:34 am

Re: Getting stuck between adjacent objects

Post 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 ;)
User avatar
pgimeno
Party member
Posts: 3655
Joined: Sun Oct 18, 2015 2:58 pm

Re: Getting stuck between adjacent objects

Post 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:
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 6 guests