Monday 2 January 2012

Better collision detection

So now I have bounding boxes to use, it is obvious from running the game that the clipping issue is much better.

Now the player UFO actually collides when you would expect it to.

Although it still rapidly bounces off walls, which isn't too bad as you would blow up anyway.

The biggest issue is when the player UFO lands on the top of a building, it flickers like crazy because of this bouncing. It doesn't look as if has landed. It's looks like it is having a fit!

This is because I'm reversing the velocity upon collision. Which is fine for the x and z axis but doesn't really help on the Y axis.

Also the world matrix for the objects is calculated in the update based on the current object position. Then the collision is checked, then the object is drawn.

When the collision is checked it resets the position but not the world, So when it comes to draw it, it actually draws the intersecting frame.

Easily fixed by storing the safe world matrix and using that when drawing the object.

This is common practice, check for collision and reset before you even draw it's position, then you never see the intersection.

So now the collision works well and I think is acceptable.

My only issue is what to do on a collision. If the player UFO touches the side of a building, then it's bad. However if it touches the top then it shouldn't die as it should be landed.

No comments:

Post a Comment