Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualh4tt3n

Posted 19 October 2012 - 12:12 AM

The value of gravityAccel is actually a force, not acceleration. You need to multiply it with mass to get the proper acceleration. Also, you need to include the masses of both objects in your gravity equation. Finally, ALWAYS apply opposite equal forces, otherwise your simulation will not conserve momentum. For two interacting objects a and b; when adding force f to object a, always add force -f to object b.

Cheers,
Mike

#1h4tt3n

Posted 19 October 2012 - 12:12 AM

// time step is based off the time between frames
float dt;
const double G_Constant;

Vec3 gravityAccel = (G_Constant*objMass/distSqu) * direction  ;
velocity -= gravityAccel * dt;

the value of gravityAccel is actually a force, not acceleration. You need to multiply it with mass to get the proper acceleration. Also, you need to include the masses of both objects in your gravity equation. Finally, ALWAYS apply opposite equal forces, otherwise your simulation will not conserve momentum. For two interacting objects a and b; when adding force f to object a, always add force -f to object b.

Cheers,
Mike

PARTNERS