Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.48 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Brick : MonoBehaviour {
  5. public int maxHits;
  6. private int timesHit;
  7. private LevelManager levelManager;
  8.  
  9.     // Use this for initialization
  10.     void Start () {
  11.     timesHit = 0;
  12.     levelManager = GameObject.FindObjectOfType<LevelManager>();
  13.     }
  14.    
  15.     // Update is called once per frame
  16.     void Update () {
  17.    
  18.     }
  19.     void OnCollisionEnter2D (Collision2D col) {
  20.     timesHit++;
  21.     if (timesHit >= maxHits){
  22.     Destroy(gameObject);
  23.     }
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement