daily pastebin goal
32%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class CameraController : MonoBehaviour {
  5.  
  6.     public GameObject player;
  7.  
  8.     private Vector3 offset;
  9.    
  10.     private bool paused = false;
  11.  
  12.     void Start ()
  13.     {
  14.         offset = transform.position - player.transform.position;
  15.     }
  16.  
  17.     void LateUpdate ()
  18.     {
  19.         transform.position = player.transform.position + offset;
  20.     }
  21.    
  22.     void Update(){
  23.         if(Input.GetKeyUp(KeyCode.P)){
  24.             if(!paused){
  25.                 paused = true;
  26.                 Time.timeScale = 0;
  27.             } else {
  28.                 paused = false;
  29.                 Time.timeScale = 1;
  30.             }
  31.         }
  32.     }
  33. }
RAW Paste Data
Top