Added different behaviour depending on whether the sphere is on the surface or not.