N1warhead

PlayerHealth

Sep 20th, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. // THIS IS THE HEALTH FOR YOUR PLAYER.
  2. // ATTACH THIS TO YOUR PLAYER.
  3.  
  4. using UnityEngine;
  5. using System.Collections;
  6.  
  7. public class BasicHealth : MonoBehaviour {
  8.  
  9.  
  10. public float maxHealth = 60;
  11. public float curHealth;
  12.  
  13. void Start(){
  14. curHealth = maxHealth;
  15. }
  16.  
  17. public void TakeDamage(float amt) {
  18. curHealth -= amt;
  19.  
  20. if(curHealth <= 0) {
  21.  
  22. Die();
  23. }
  24. }
  25.  
  26. void Die() {
  27. Debug.Log ("Dead");
  28. Destroy (this.gameObject);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment