I noticed that your version doesn't update the velocity vector at all. I think it might be better to go back to basics, often the best way when calculations don't pan out:
1. Calculation the force due to gravity, as per Bacterius's post.
2. Convert it to acceleration, using F=ma.
3. Make the acceleration into a vector, e.g. the unit vector towards the gravity source times a.
4. Update the velocity with the acceleration and time, e.g. add the acceleration vector times the time.
5. Add the velocity to the position.
You can get fancier on top of that, e.g. interpolate the acceleration from one frame to another, then interpolate the velocity based on that, then get the position. Calculus in the house. ;) But that should be a good start if you run your physics frequently.
I didn't update the velocity because dY = Vy0*t = .5*a*t^2 doesn't call for it. I'll try out your method of simply updating the velocity based on the acceleration instead of getting dY and see how that works out.
[quote name='homer_3' timestamp='1336532148' post='4938565']
I thought you subtracted the position of the other guy from yourself to get a vector going from yourself to the other guy.
You have it backwards.
[/quote]
Say the well is at 8,2 and the object is at 4,6.
8-4 = 4
2-6 = -4
This gives me a vector of 4,-4. Adding that vector to 4,6 (the object caught in the well) will put me at the center of the well. I don't see how subtracting my target's position from my position will give me a vector going from me to the target.
[quote name='homer_3' timestamp='1336532148' post='4938565']
Getting the acceleration based on the distance the object is from the well isn't all that important to me. A constant acceleration will work just fine.
Then you are not modeling a gravity well, but something else... which might explain why it doesn't behave like you expect.
[/quote]
I'd expect a constant acceleration to still pull the object towards the well...
Another thing worth mentioning is that a real, physically accurate gravity field cannot "catch" stray objects and make them spiral into itself. This is only possible if you add some sort of friction that dampens motion over time. Would you like to see some simple code samples (100-200 lines) of gravitational interaction?
Cheers,
Mike
So you are saying that if you were out in space and tried to throw a baseball tangent to Earth and the basball wasn't moving at escape velocity, it wouldn't fall to Earth?