Avoid one gameObject skin in another gameObject

Let say i have two gameObject, one is sphere another is cube.
While sphere position is control by mouse cursor(sphere follow the move position).
But my sphere will skin in the cube, when my cursor near to cube 1B.

I perfer the sphere will not skin in the cube.

Is Unity3D have any way to make the sphere look like in picutre 1A. The sphere just touch or not skin in the cube like.

I have try add collider and rigidbody, but it is still skin in.

alt text

Update 1

i have a hand model that have animation, i expect the hand can grasp something in the game.(i trigger the hand animation to grasp the object)

But what i got is the hand will skin in the object like 2B, i hope the hand will automatically stop when it touch the object like 2A.

alt text

It depends on how you control the sphere. If you use transform.position or transform.translate for positioning you disallow all rigidbody calculations for physic movement. How about attaching a spring joint from an empty gameobject which is controlled by the mouse to the sphere?

What you probably want to do is set up a raycast so the sphere raycasts towards the cube. Then if the distance of the raycast is less than half the width of you sphere, you can translate the position of the sphere away from the cube by .5 - raycast.distance.

Code to put on Sphere:

var direction: Vector3;
var hit: RaycastHit;
var newdist = 0.0;

function Update(){
direction = transform.TransformDirection(Vector3.right);
if(Physics.raycast(transform.position, direction, hit)){
   if(hit.distance < .5){
     newdist = .5 - hit.distance;
            transform.translate(-Vector3.right * newdist);
    }
  }
}