Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class BricksScript : MonoBehaviour
- {
- //Amount of life of the brick
- public int life = 1;
- //Each time the brick collides with anything
- private void OnCollisionEnter(Collision collision)
- {
- //If it has "Ball" tag
- if(collision.gameObject.tag == "Ball")
- {
- //decreasing life
- life--;
- //if life is lower or equal 0
- if(life <= 0)
- {
- GameManager.instance.bricks.Remove(this.gameObject);
- Destroy(gameObject); //Destroy the object
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment