FollowingPlayer

using UnityEngine;
using System.Collections;

public class FollowingPlayer : MonoBehaviour
{
  public float cameraHeight = 17.0f;
  public float cameraDistance = 17.0f;
    
  private Transform playerPosition;
  
  void Start()
  {
    playerPosition = GameObject.Find("Player").transform;
  }
  
  void LateUpdate( ) 
  {
    transform.position = playerPosition.position + 
      new Vector3(cameraDistance, cameraHeight,           -cameraDistance);
    transform.LookAt(playerPosition);
  }
}

Get Learning C# by Developing Games with Unity 3D Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.