How to change the position of the camera when colliding with a GameObject?

I want to change the position of the camera to a certain position when the player collides with this GameObject. I’ve made the GameObject into a rigidbody (non-kinematic). Still, it doesn’t seem to work. I’m not very good at UnityScript because I’m just starting out, but this is what I have so far (again… I’m not very good):

var sceneCam : GameObject;
sceneCam = GameObject.Find("MainCam");

function OnCollisionEnter(theCollision : Collision){
 if(theCollision.gameObject.name == "Player"){
 sceneCam.transform.position = Vector3(-20.46, 4.258904, -805.3136);
}
}

EDIT: Is there any way to make the position change smoothly? I’ve heard of Time.deltaTime… but I’m not familiar with how to use it.

Thanks guys, any help is appreciated.

Yeah, you can move camera smoothly with Lerp function. I will write down some simple code for you (it is in C# but in JS it should be very similar).

// Strength the camera will follow, between 0 and 1.0. Making it too strong may cause jittering
public float strength = 0.5f;

void MoveCamera() {
 Vector3 cameraPosition = new Vector3(-20.46, 4.258904, -805.3136);
 sceneCam.transform.position = Vector3.Lerp(transform.position, cameraPosition, strength);
}