Tile Based Collision Edges - Argh, I'm stuck.

I’ve got a tile based map (see http://67.18.194.226/kev/grav2/grav2pg.jnlp). I have a non tile shaped ship colliding with the tiles. While I can happily tell when the ship has collided with a tile (using java.awt.geom.Areas), I now want to know which side of the tile was collided with (and hence the normal) to work out the bounce correctly.

Now, I’ve tried a few bits and pieces but all are horribly hacky…

Anyone got any ideas how to do this?

Kev

I was struggling with something like this a while ago, about the most general solution is to test all the line segments of one object against all the line segments of the other. That’ll give you a few segments that intersect, and if you’re lucky one of them will be a tile edge. If you’re unlucky you’ll get two tile edges when you bump into a corner. If you’re really unlucky you’ll get three edges when you totally swarm over an edge.

You could try seperating all the cases, but that could be tricky. A more mathematical way would the method of separating axies, which gives you a separation plane and penetration distance. Google should have quite a bit on it.

If you’re sure one will always be static (like with tiles) and all your tiles are the same shape then you can probably simplifiy things quite a lot. For a start you should be able to use your velocity to trim down the possible edges to one or two (can’t bump into an edge you’re moving away from :wink: ).

And thats thats :slight_smile: Velocity trimming plus a bit of jiggery pokery has sorted it. I have 5 different tile shapes and it all seems to work happily.

Thanks,

Kev