Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class cameraMovement : MonoBehaviour {
  5.     public float speed;
  6.     public bool gameOver;
  7.  
  8.     void Start(){
  9.  
  10.     }
  11.  
  12.     void Update(){
  13.  
  14.         if(!gameOver){
  15.             transform.Translate(1 * Time.deltaTime * speed,0,0);
  16.         }
  17.     }
  18.     public void GameOver(){
  19.         gameOver = true;
  20.     }
  21.  
  22.  
  23.     void OnTriggerExit2D(Collider2D col)
  24.     {
  25.         if(col.gameObject.tag == "Player"){
  26.             Destroy (col.gameObject);
  27.             UI_Menu.gameOver = true;
  28.             var CameraObjects = FindObjectsOfType<cameraMovement>();
  29.             CameraObjects[0].gameObject.SendMessage("GameOver");
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement