Making cubes stop when they touch each other

Hi all

At the moment i have a script which when you hit a cube, it starts to follow you…which works fine. But if i hit two cubes and they start to follow me, they clip inside of each other…i dont want this. Both cubes have a box collider on them and the code for the follow script is:

    var target : Transform; //the enemy's target
    var moveSpeed = 3; //move speed
    var rotationSpeed = 3; //speed of turning    
    var Player = GameObject.Find("Player").transform.position;
    var Cube2 = GameObject.Find("Cube2").transform.position;
     
    var myTransform : Transform; //current transform data of this enemy
     
      
    function Update () {
    
   
    
    
    
    if (target == GameObject.FindWithTag("Player").transform)
    {
	//rotate to look at the player
	//GameObject.Find("Cube2").transform.position = GameObject.Find("Player").transform.position + 5;
    myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
    Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
    
    var distanceToPlayer : float = Vector3.Distance(target.transform.position, myTransform.position);
    
    
    if(distanceToPlayer > 2){
     
    //move towards the player
    myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
    
    }
   	
   	
    }
 
     
     
    }

Thanks for any suggestions!

Rigidbody - “Control of an object’s position through physics simulation.”

You must use rigidbodies if you want physic behaviors and collision.