Skip to main content
GameDev.net gamedev.net
🔒 Locked

Collision Detection Problem

Started by drstrangeluv Nov 20, 1999 at 7:21 PM 2 replies 900+ views
Original Post
drstrangeluv
drstrangeluv
I'm using an axis-aligned bounding box collision algorithm to do collision detection for my 3D program, but I'm encountering the following problem. As two objects get very close to each other, they eventually touch, causing the program to think that they are constantly colliding, and sending the program into an infinite loop resolving the collision. What are some options for dealing with objects "touching" each other or keeping two objects from technically touching each other?

Thanks.

Machaira
Machaira
I'm no 3D expert but from what little I've read I would think you would have to take the vectors of the objects into consideration, depending on the types of objects that are colliding. If the objects are the type that rebound, once you've done the collision checking they should be moving away from each other and you no longer need to worry about it. If the collision is resulting from, say, a player charging into a wall, you don't really need to do anything since you're collision code should know that the wall is an impassible object.

Maybe I'm totally wrong though! This is just a guess. I really need to get into 3D stuff soon.

Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development
Niels
Niels
The process should be something like the following:

1) Check for overlap, if yes goto 2

2) Issue collision event and re-position one or both of the objects so that they no longer overlap. (This is best done by moving them backwards along their movement vectors to the last point where the overlap test fails)

Asuming the objects are no longer moving, they'll not overlap again, and 1) will yield false on the next test..

The problems most people have with this is caused by floating point in-accuracy, so you might want to use a "very small" value X and replace all floating point equality comparisons

if(f1==f2)

with:

if ( abs(f1-f2)/Niels

<b>/NJ</b>

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.