Camera not move with Player

using UnityEngine;
using System.Collections;

public class CameraConroller : MonoBehaviour {

public GameObject player;
public Vector3 offset;

// Use this for initialization
void Start () {
	offset = player.transform.position;

}


// Update is called once per frame
void LateUpdate()
{
	transform.position = player.transform.position + offset;
}

}

In Start(), you’re setting your offest to the Player’s position. And then in your update, you’re setting your camera’s position to the player’s current position + whatever the player’s position was when the camera called “Start”.

Instead of setting your offset in Start(), just set it up in the inspector since it’s a public property. That vector3 acts as the position relative to your player.

Here’s my simple camera code:

using System.Collections;

public class MainCameraController : MonoBehaviour
{
	public Vector3 cameraOffset;
	public GameObject focusObject;

	void Start()
	{
		// Nothing to do here.
	}

	void LateUpdate()
	{
		transform.position = focusObject.transform.position + cameraOffset;
	}
}