Advertisement
Guest User

Untitled

a guest
Jan 31st, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CameraFollow : MonoBehaviour {
  6.  
  7.     public GameObject player;
  8.     Vector3 offset;
  9.  
  10.     // Use this for initialization
  11.     void Start () {
  12.         offset = player.transform.position - transform.position;
  13.     }
  14.  
  15.     void LateUpdate ()
  16.     {
  17.         // Set the position of the camera's transform to be the same as the player's, but offset by the calculated offset distance.
  18.         transform.position = player.transform.position + offset;
  19.     }
  20.    
  21.     // Update is called once per frame
  22.     void Update () {
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement