Moving the Camera

Checked with version: 5

-

Difficulty: Beginner

Moving the camera relative to the player.

Moving the Camera

Beginner Roll-a-ball tutorial

Transcripts

CameraController

Code snippet

using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour {

    public GameObject player;

    private Vector3 offset;

    void Start ()
    {
        offset = transform.position - player.transform.position;
    }
    
    void LateUpdate ()
    {
        transform.position = player.transform.position + offset;
    }
}

Related tutorials