CakeMeister

BOX1 scripts phan 16

Jul 13th, 2017
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class BOX1 : MonoBehaviour {
  6.     public int Health = 100;
  7.     public AudioSource audiosrc;
  8.     public AudioClip box;
  9.  
  10.     private void Start()
  11.     {
  12.        
  13.         audiosrc = gameObject.GetComponent<AudioSource>();
  14.     }
  15.     // Update is called once per frame
  16.     void Update () {
  17.         if (Health <= 0)
  18.         {
  19.             Destroy(gameObject);
  20.         }
  21.     }
  22.  
  23.     void Damage(int damage)
  24.     {
  25.         audiosrc.PlayOneShot(box, 0.8f);
  26.         Health -= damage;
  27.     }
  28. }
Add Comment
Please, Sign In to add comment