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

DistanceGrid with Slopes (Sharp Edges)

Jul 6, 2009 at 5:12 AM

Hi all,

After having some problems with the SAT, I've decided to give the DistanceGrid narrow-phase a go. So far it's working very well, but I have one minor problem:

Youtube video, as usual:

About 6 seconds in, you can see my difficulty - I want the block to move up the slope smoothly, rather than going into it slightly and getting stopped. I'm thinking the problem is related to the slope having a sharp point where it meets the ground - I've tried adding more and more vertices, and also reducing the grid size (all the way down to 1), but while most of the other scenarios are rock-solid, I can't get this to work. It's really important for my game... any tips on how I can coax it into behaving nicely?

Thanks again

Jul 6, 2009 at 3:56 PM

Try adding even more points around the sharp edge. To me it looks like the first vertices is ignored and then the second one on the side stopps the "player".

You need to add even more points and give it a lower cell size (try with lower than 1 - start with 0.1 and see if it works and then go up until it does not work anymore, then use the previous value you tried. It is a precision/speed trade-off).

Another thing you can try is to simply not have sharp edges. If you use the triangle as a part of a static terrain, then you can lower it a bit so the point of the triangle is inside the other geometry. This will limit the problem a bit.

You can also round the corners of the triangle. A lot of games actually round the corners to prevent both tunneling and unstable collisions.