Gravity wells?
Posted: Sun Jun 13, 2010 9:55 pm
Hi all,
I was wondering if any of you had any ideas as to how gravity wells should be properly implemented. By that I mean designating points on the space to which objects can be attracted, like a black hole or a similar massive object.
My first idea was to simply calculate the vector to the gravity well at every tick using the common formula of gravitational acceleration, and add that vector to the velocity of the body, or apply an impulse using the same vector. Both these approaches proved problematic, however, since when the object gets close enough the gravity vector becomes huge, which causes the object to simply shoot past the center and end up offscreen (and since the distance is now pretty far, the object doesn't gravitate back).
To mitigate this, I tried making sure the object's velocity never causes it to go past the center, and this works. However it yields the effect of the objects slowing down as they approach the gravity well, which is not the effect I want.
Has anyone implemented a semi-realistic looking gravity well?
I was wondering if any of you had any ideas as to how gravity wells should be properly implemented. By that I mean designating points on the space to which objects can be attracted, like a black hole or a similar massive object.
My first idea was to simply calculate the vector to the gravity well at every tick using the common formula of gravitational acceleration, and add that vector to the velocity of the body, or apply an impulse using the same vector. Both these approaches proved problematic, however, since when the object gets close enough the gravity vector becomes huge, which causes the object to simply shoot past the center and end up offscreen (and since the distance is now pretty far, the object doesn't gravitate back).
To mitigate this, I tried making sure the object's velocity never causes it to go past the center, and this works. However it yields the effect of the objects slowing down as they approach the gravity well, which is not the effect I want.
Has anyone implemented a semi-realistic looking gravity well?