Unity How to follow a player with a camera

Attach this script to a camera (Main Camera for example). Make sure your player object is tagged.

FollowPlayer.cs
using UnityEngine;
using System.Collections;
 
public class FollowPlayer : MonoBehaviour {
	public Vector3 offset = new Vector3(0,0,-1);	
	private Transform player;
 
	void Awake () {
		player = GameObject.FindGameObjectWithTag("player").transform;
	}
 
	void Update ()	{
		// Set the position to the player's position with the offset.
		transform.position = player.position + offset;
	}
}
Navigation
Print/export
Toolbox