This project has moved and is read-only. For the latest updates, please go here.

One way collisions?

Topics: Developer Forum, User Forum
Dec 16, 2009 at 9:38 PM

Is it possible to have a one way collision?

Like in a jump'n'run, having the player jumping up through a platform and then land on it. No collision passing through on the way up, but collision triggered on the way down.

Dec 16, 2009 at 9:49 PM

One way might be to check the linearvelocity.Y of the player, if it's positive or close to zero there will be a collision, if not there will not be a collision. Or combine this with the location of the collision point, if it's above or below the player

Dec 16, 2009 at 9:59 PM

or I just thought of another way, you could have a different collisioncategory on the floor vs the ceiling of your objects, if you hit the ceiling you could start a timer that you can not collide with the floor for the time it takes to come back down. There are many more ways all depending on the type of levels etc you plan to use


Dec 16, 2009 at 11:00 PM

I would keep a list of geometry that is one-way passable, and each frame test your player's body position against it.  If the player is below the platform then add it to the player's collision group so that it passes through.  If the player is above it (and then likely to come down onto it) make sure it is not in the player's group.

Dec 17, 2009 at 11:54 AM

Thanks for the response.

So there's no one way type of edges or so to use?

Dec 17, 2009 at 12:16 PM
Edited Dec 17, 2009 at 12:17 PM

You can check the normal of the collision side. If the collision happens from the lower side of the geom, the ignore it. I think there's a thread here explaining how this should be implemented, but I can't find it right now.

Dec 19, 2009 at 11:32 PM

Is it possible to create a single line for collision to check against? I've not quite managed and the code I have at the moment (using a 40 x 1 pixel box as platform) is performing very oddly when I check the normals (the player get "thrown out" of the object, rather than pass through).

Dec 20, 2009 at 9:55 AM

Found out how to manually do a one line geom. But the problem still remain.