Skip to main content
gamedev.net
🔒 Locked

Constant Acceleration ?

Started by Endemoniada 1 reply 350+ views
Original Post
Endemoniada
Endemoniada
Hi guys, I am using constant acceleration but am not sure what velocity to use in my collision detection. Like this (pseudo-code): void MoveObjects(float time_span) { // add up all the forces // compute next position using constant acceleration // what velocity do I use now ? // collision loop do{ delta=time_span*velocity; // see if anything collided // then move to collision spot // and record time object.position += delta*time_span; object.velocity = reflected velocity; }while(time still left) } If after I accumulate the forces and get an acceleration and calculate the object''s next position it will be using the average velocity, but the ''real'' velocity (at the end of the frame) will be v=v + at. So I don''t get it. I want the collision loop to use linear movement so it seems logical to use the average velocity, but at the same time it isn''t the ''real'' velocity at the end of the last frame. Also, if I save the new velocity for the next frame and the current velocity gets altered in the collision response loop it messes things up. Any ideas ?
EvilProgrammer
EvilProgrammer
Your timesteps should be small enough that taking the average velocity instead of the instantaneous velocity for collision detection shouldn''t make too much of a difference. Then after every frame you set the object''s current velocity to what it would be: V(t) = V(0) + at. After you respond to the collision, the velocity will be different anyway.

Topic Locked

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

Sign in to reply to this topic.