how do I get a camera to follow an object?

I’m trying to have a camera follow an object floating in Ocean 3v. Basically a 3rd person view of a boat driving through the water. I’ve come up w/ this but it doesn’t do anything and I’m not certain why.

var Structure: Transform;
var CameraOffsetX: double;
var CameraOffsetZ: double;

private var Spread: Transform;

function Update () {
var follow = GetComponent(Transform).Transform;
Spread.position.x = Structure.position.x + CameraOffsetX;
Spread.position.z = Structure.position.z + CameraOffsetZ;
follow.position = Spread.position;
}

The reason I’m moving the camera instead of attaching a camera as a child is because Ocean 3v nicely follows the main camera making it look like you’re driving through the water. The game plan is to use the bouyancy script as it hits a wave while having the camera follow the boat. Plus I want the boat to rock w/o the camera rocking as well.

If there’s a better way to do this I’m all ears.

can’t you use the smooth follow in the defult assets?!

yeah umm… Dude… Hate to break it to you but unity3d comes with a script called “SmoothFollow”
its a cam script so just put itin you main camera and set the target and distance.

if you trying to make your OWN then i cant really help you.

I was completely unaware of that, it works great. Thanks.