Advertisement
LegitTeddyBears

Shootable

May 26th, 2017
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Shootable : MonoBehaviour
  5. {
  6.  
  7.     //The box's current health point total
  8.     public int currentHealth = 100;
  9.  
  10.     public void Damage(int damageAmount)
  11.     {
  12.         //subtract damage amount when Damage function is called
  13.         currentHealth -= damageAmount;
  14.  
  15.         //Check if health has fallen below zero
  16.         if (currentHealth <= 0)
  17.         {
  18.             //if health has fallen below zero, deactivate it
  19.             gameObject.SetActive(false);
  20.         }
  21.     }
  22.  
  23.     private void Update()
  24.     {
  25.         Debug.Log(currentHealth);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement