Simplicity... love it. Okay, I hit just this snag at one time and here's how I got around the problem (this assumes you're using Blitz 3D).
1) Create a pivot which is the PARENT of the object you are applying gravity to.
2) Then in each loop:
3) De-parent the object.
4) Point the pivot at the target sphere./
5) Re-parent the object.
6) Move the pivot by gravity speed.
Heres some code in action:
Graphics3D 640, 480
SetBuffer BackBuffer()
Global pivot = CreatePivot()
Global cube = CreateCube(pivot)
Global world = CreateSphere(16)
Global cam = CreateCamera()
Global gravity# = 0.01
Repeat
EntityParent pivot, 0
If KeyDown(200) MoveEntity cube, 0, 0, .01
If KeyDown(208) MoveEntity cube, 0, 0, -0.01
; The following simulates thrusters for moving away from the surface
; NOTE: this is an example. Fiddling with gravity is not recommended :)
If KeyDown(57)
gravity# = -0.01
Else
gravity# = 0.01
EndIf
; Position the entity at our cubes exact position
PositionEntity pivot, EntityX#(cube,1), EntityY#(cube,1), EntityZ#(cube,1)
; Point the pivot at the planet
PointEntity pivot, world
; Re-parent the cube
Entityparent cube, pivot
; Move the objects
MoveEntity pivot, 0, 0, gravity#
Until Keyhit(1)
This is similar to Shamblers suggestion, but it allows you to retain the current rotation of your object.