One way collisions?

Topics: Developer Forum, User Forum
Dec 16, 2009 at 8: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 8: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 8: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 10: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 10:54 AM

Thanks for the response.

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

Dec 17, 2009 at 11:16 AM
Edited Dec 17, 2009 at 11:17 AM

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 10: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 8:55 AM

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