drmcnellis / collisiondetectionkit

Automatically exported from code.google.com/p/collisiondetectionkit
0 stars 0 forks source link

Predictive Collision Detection #16

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
also known as Sweep Testing, Frame Independent Detection, Continuous Collision 
Detection - this sort of Collision Detection prevents case scenarios where 
objects moving too fast can pass thru barrier objects, because their positions 
in space never collide on a frame.

I read an excellent article on the subject here: 
http://sebleedelisle.com/2010/01/predictive-collision-detection-techniques/

Are there any plans on adding something like this to the CDK?

Original issue reported on code.google.com by h3liumdr...@gmail.com on 8 Nov 2010 at 6:05

GoogleCodeExporter commented 9 years ago
How do you change issue type from Defect to Enhancement?

Original comment by h3liumdr...@gmail.com on 8 Nov 2010 at 6:06

GoogleCodeExporter commented 9 years ago
I am using the CDK in my code, and figured out a way to perform my own sweep 
tests!

in my game, when you enter a frame, a tick function is invoked on things like 
ships and shots, this handles their movement.  

i was having a problem with fast moving shots, the point at which they would 
collide with an object was not on a frame - so often the shots would cruise 
right past the target.

the issue here is where and when the checkCollision is called.

previously I was calling onEnterFrame.

the solution - during my tick function, there is a timestamp.
you can keep track of when the last tick, and subtract that from the current 
tick to keep track of the offset.  

the offset is how many miliseconds have past since the last frame(tick).  

for( var a:int=0;a<offset;a++){  //this code will execute once per milisecond, 
durring the time between frames.  this keeps my bullets moving at constant 
pace, regaurdless of framerate.

so i use this loop, and call for collisionChecks there.  essentially this 
allows you to call collisionChecks between frames.

Original comment by h3liumdr...@gmail.com on 8 Nov 2010 at 8:06