I would like to use this script to have the object with this component automatically look at the main camera. How can I do this? I don’t want to have to drag the camera into the target variable
// This complete script can be attached to a camera to make it
// continuously point at another object.
// The target variable shows up as a property in the inspector.
// Drag another object onto it to make the camera look at it.
var target : Transform;
// Rotate the camera every frame so it keeps looking at the target
function Update() {
transform.LookAt(target);
}
Assets/Scripts/lookatCamera.js(1,9): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/Scripts/lookatCamera.js(1,18): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/Scripts/lookatCamera.js(2,8): BCE0044: expecting :, found ‘=’.