Public Group

Help!Bounding collisions

This topic is 3469 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Ok so im working on a 2d pong game on XNA;to check for collisions,ive created bounding rectangles for every object...now the problem that im having is that sometimes....when the ball speed gets very high,the bounding rectangle of the ball crosses over the bounding rectangle of the pong without really intersecting it.... im doing something like this .....ballvector.X+=speed*gametime.elapsedmilliseconds and ballvector.y+=speed*elapsedmilliseconds.......now when X and Y attain a value that is larger than the height of the pong and the ball combined,they just cross over without the two rectangles actually intersecting each other...resulting in a ghost effect with the ball seeming to pass through the pong,how do i overcome this...without creating larger bounding rectangles?

Share on other sites
Its called tunnelling.

The objects collision is only tested after its passed through the other object in question. In simple form you need to test you collision over time.

EDIT: Diagram:

intial test (no collision still hasn't reached yet).
    |o   |    |

next frame (still no colliding but wait thats not right :) ):
    |    |    o    |

It never collided within a frame bound test.

You need do something like this within each frame bound test ( each 'o' is a time segmented collision test, big O is the detected collision):

    |oooO|oooo    |

Share on other sites
thnx....so basically i need to run a loop AFTER the object has crossed over and check whther it shouldve collided or not by incrementing the speed of the object in small amounts when the ball was at its previous location?that does seem a bit logical........but then i will also have to run a loop and check whether the ball has crossed every other objects x or y location each time it moves.....wont i?....

Share on other sites
I'll not pretend like I am an expert, to be honest I would probably take the lazy route of using code/library that someone else put the nessescary time into. Its good to know it and one day I might put the effort in but...

Its called a sweep test this is one example:

Sweep test

• 32
• 12
• 10
• 9
• 9
• Forum Statistics

• Total Topics
631349
• Total Posts
2999473
×