Object controlled with mouse passing through other objects

Hi guys, I have a cube controlled with this script:

var hit : RaycastHit;
var kocka : GameObject;
function Start () {

}

function Update () {
	
	if (Input.GetMouseButton(0)) {
	
	var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
	
	  if (Physics.Raycast (ray, hit)) {
	   kocka.transform.position.y = hit.point.y;   
	   }
    }
      
    if (Input.GetMouseButtonDown(0)) {
       kocka.rigidbody.useGravity = true;
    }    
}

Cube I’m controlling is passing through other objects, but I don’t want it. I have added rigidbody to Cube and other object, and set Collision Detection to Contionuos.

When using rigidbodies you cannot adjust the transform’s positionmanually, as this will effectively circumvent any collision detection as you are setting the position directly, no matter if any collision happened. For rigidbodies use AddForce or similar, or use a CharacterController and look at Move() / SimpleMove().

Hi,

I tried with rigidbody.AddForce, but cube is still passing through other cube.
Can you explain a little bit more?

HELP please!?!?