camera follow script unity code example
Example 1: camera follow
public Transform player;
public Vector3 offset;
void LateUpdate()
{
transform.position = player.position + offset;
}
Example 2: camera follow player unity smooth
Vector3.SmoothDamp(cam.position, transform.position + cameraOffset, ref cameraVelocity, CameraFollowSmoothTime);
cam.position = cam.position + cameraVelocity * Time.deltaTime;
Example 3: linerenderer follow camera unity
You can render the line using a dedicated camera. Use .depth to control the order in which cameras render (i.e. render the line on top of -everything-), and .cullingMask to define what each camera renders (or not).
http://unity3d.com/support/documentation/ScriptReference/Camera-depth.html
http://unity3d.com/support/documentation/ScriptReference/Camera-cullingMask.html