Asteroids icon indicating copy to clipboard operation
Asteroids copied to clipboard

Collision detection fails

Open MunWolf opened this issue 8 years ago • 3 comments

This tends to happen when a bullet passes through an asteroid and the asteroid moves just enough so the line that is made from the current and last position of the asteroid is fully inside him.

A quick fix for this that wouldn't cover the edge cases is to do a radius check between the bullet and the asteroid with a circle that is fully encompassed by the asteroid so the bullet can't just pass through the center.

I don't see a better way atm since it doesn't happen every time and depends mostly on luck.

This is what I think the problem is but with some asteroids I never get a collision even if I hit them dead center.

MunWolf avatar Dec 16 '16 14:12 MunWolf

Would be good if we could get some tests for that.

meiamsome avatar Dec 16 '16 15:12 meiamsome

Marking for testing in case this comes up again.

meiamsome avatar Dec 17 '16 03:12 meiamsome

We found out in the Asteroids++ repo that this is happening because when the vertices for the asteroid are calculated we do not connect the last vertex with the first one.

MunWolf avatar Dec 17 '16 19:12 MunWolf