# 2D collision - "jumping"

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

## Recommended Posts

hi! i do have question about one thing. i'm trying to do 2D collision with sprites. i'm using the simplest way to do it - collision of 2 rectangles... it's works fine... the problem comes when i'm trying to put some dynamics into my program. let's say the object1 has speed 10. an object2 has width 2...object1 is going onto object2... in most cases the collision won't be detected because object1 simply "jumps over" object2... i have a few ideas how to solve it but i want to hear some advice from experienced people...so i'm not going to reinvent the bad wheel... thx

##### Share on other sites
I use a system that predicts collisions instead of detecting them. Since I predict the time of collision mathematically, no misses can occur.

Other ways may involve using swept areas/volumes or multisampling (reducing the time step in artificial ways).

##### Share on other sites
I'm no expert, but I have thought on the matter.

Here's an image that shows what I've thought about with regards to 2d collision detection algorithms.

Basically you keep testing until all collision lines and objects do not intersect with any other objects or collision lines.

It is important to step based on the time rather than the position of the start of intersection. Update position in response to updating time and keep time moving at a percent of the fastest object.

##### Share on other sites
Quote:
 Original post by M2tMI'm no expert, but I have thought on the matter.Here's an image that shows what I've thought about with regards to 2d collision detection algorithms.Basically you keep testing until all collision lines and objects do not intersect with any other objects or collision lines.It is important to step based on the time rather than the position of the start of intersection. Update position in response to updating time and keep time moving at a percent of the fastest object.
The above method might work with some tweaking (I'm not sure), but I just wanted to mention that for boxes and circles at least there are established algorithms for swept intersection that are robust and will handle all cases (within numerical limits). Box vs. box can be done using the separating axis theorem, circle vs. circle involves solving a quadratic, and box vs. circle is a little more complicated and can be approached a few different ways. Anyway, I just mention this because the OP said he didn't want to reinvent the wheel :)

Also, it sounds like the OP just needs a swept AABB vs. AABB test, which is fairly easy to code and is described in a gamasutra article linked in the 'collision detection' section of gdnet articles (I believe the author is Gomez).

##### Share on other sites
Read this. It even has free code. Praise Oliii when you are done.

• 10
• 18
• 14
• 18
• 15