• Create Account

### #ActualSelenaut

Posted 30 January 2013 - 11:28 AM

Okay, so I came up with this formula for finding the precise moment of impact.
t = the amount of time one discreet timestep takes (currently set at 1/60 of a second)
mv = magnitude of the velocity vector (x & y change each stimestep by t*velocity, with respect to each axis)
p = the amount the moving object penetrated past the collision point as measured by the wall's normal (0 if it didn't collide)
θv = angle of the velocity vector
θw = the angle of the wall

The amount of time the object should move is equal to t - (|p/sin(θvw)|/mv). Then it bounces, and runs the rest of the timestep. I'm almost certain this is correct, right?

Well, I'm getting a bug where when it corrects, the object bounces, but flies off the screen when the bounce height gets near 0. Within a second, its coordinates are in the billions (bouncing off the walls of a 640*480-ish window - obviously a problem.) So, err..... Yeah. Any ideas?

Selenaut

### #1Selenaut

Posted 30 January 2013 - 10:24 AM

Okay, so I came up with this formula for finding the precise moment of impact.

t = the amount of time one discreet timestep takes (currently set at 1/60 of a second)

mv = magnitude of the velocity vector (x & y change each stimestep by t*velocity, with respect to each axis)

p = the amount the moving object penetrated past the collision point as measured by the wall's normal (0 if it didn't collide)

θv = angle of the velocity vector

θw = the angle of the wall

The amount of time the object should move is equal to t - (|p/sin(θvw)|/mv). Then it bounces, and runs the rest of the timestep. I'm almost certain this is correct, right?

Well, I'm getting a bug where when it corrects, the object bounces, but flies off the screen when the bounce height gets near 0. Within a second, its position is within the billions (bouncing off the walls of a 640*480-ish window.) So, err..... Yeah. Any ideas?

Selenaut

PARTNERS