#### Archived

This topic is now archived and is closed to further replies.

# Collision Time / Time Based Collision

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

## Recommended Posts

Heres my current algorithm Pos // PositionOf object GameLoopStart OldPos = Pos; // making copy of position IF (CollisionDetected) GetNewVelocity and Pos = Old Pos Keep Moving with a velocity GameLoopEnd It works acceptable with slow moving objects. But collosion is detected when colliding object already crossed the plane of that object. This algorithm''s inaccuracy results into loss and gain of energy of system. I need to find the exact time at which objects collides with a given verlocity.?

##### Share on other sites
Are you sure you''re going about it the right way?

If you want to know where to put your object after the collision, then intersect it with where it hit.

If you want to "roll back" time that you''ve moved so you can have more accurate inter-object collision, then you can either...

* Find the intersection, as above, and calculate how much of the frame time happened before the collision occurred

or

* Use a "binary search" approach with time and iterate around using smaller time steps until you reach close to where you think the collision occurred.

Hard to describe, but I hope you get the idea.

Why you shouldn''t use iostream.h - ever! | A Good free online C++ book

##### Share on other sites

""If you want to "roll back" time that you''ve moved so you can have more accurate inter-object collision, then you can either...""

YES

""* Use a "binary search" approach with time and iterate around using smaller time steps until you reach close to where you think the collision occurred.""

I found this easy i will do this. but could you also explain the former method too.

##### Share on other sites
I think using the old position and the new position, find out the fraction of the total movement where the object was stopped. Basically that''s "distance between intersection and old pos / distance between new pos and old pos".

Then you''d end up with a float from 0 to 1. 0 meaning that the object was stopped at its start position, and 1 meaning the object was stopped at the end position.

Then you can just multiply your frame time by that float to find out when the intersection occurred.

Hope this helps.

Why you shouldn''t use iostream.h - ever! | A Good free online C++ book

##### Share on other sites
Oh yes thats great

1. 1
2. 2
Rutin
20
3. 3
khawk
17
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633756
• Total Posts
3013710
×