マグネットのような物でよければ簡単
ball.apply_central_force(magnet.position - ball.position)
これだと磁力=距離なので適宜修正は必要