How to rotate cube2 if the script is in cube1?

What i want to do is to rotate the cube2 when the cube1 collides with it, i know i could put the script on the cube2 and test if they are colliding, but with all the thigns i will have it won’t be possible to do that, and i want to know how i would do that, cuz in my point of view it’s a important thing to know.
Basically i have this javascript script on cube1:

function OnCollisionEnter(col : Collision){

	if(col.gameObject.name=="cube2"){
		Debug.Log("Hit Something");
	}
}

Probably i’ll use transform.Rotate, but i need to tell the program that is the cube2 that needs to rotate and not the cube1.
Thanks!!

You have a direct reference to the game object you’ve collided with in the event handler. In fact, the code you’ve posted is already referencing it.

You can access the transform of the “cube2” object like this:

function OnCollisionEnter(col : Collision) 
{
     if(col.gameObject.name == "cube2") 
     {
         col.transform.Rotate(someNewVector3);
     }
 }