object following the camera

How can I make an object follow a camera.

Basically I have a camera moving in the y axis : var up : Vector3;

function Update () { // Set's the rigidbody velocity to be // along the green axis of the transform rigidbody.velocity = transform.up * 10; }

If all you want is the object to be following the camera of one axis you could just set the position of the object to be in a certain position relative to the camera.

For Example you would attach this to the camera.

var cameraToFollow : Transform;

function Update () {
     transform.position.z = cameraToFollow.position.z + 10;
}

This would just set the position of the object 10 away on the z axis.

You could also make the object parent to the camera (just drag the object inside the camera) in the hierarqui