Giving an object it's own gravity

I’m attempting to make a controllable ball have it’s own gravity so that the characters head moves independently of the ball but will stay ‘semi-attached’ e.g will always gravitate back to the ball.

The best example I can think of is the robot bb-8 from the new Star Wars movie where the head moves independently of the body.

I’m not entirely sure how to achieve this, any assistance would be great!