Advertisement
N1warhead

PlayerHealth

Sep 20th, 2014
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. public float maxHealth = 60;
  10. public float curHealth;
  11.  
  12. void Start(){
  13. curHealth = maxHealth;
  14. }
  15. // THIS GIVES HEALTH (CHANGE TAKEDAMAGEE) TO WHAT YOU LIKE, JUST BE SURE TO CHANGE THE NAME IN ADD HEALTH SCRIPT.
  16. public void TakeDamagee(float amt) {
  17. curHealth += amt;
  18. }
  19. // THIS TAKES HEALTH!!
  20. public void TakeDamage(float amt) {
  21. curHealth -= amt;
  22.  
  23. if(curHealth <= 0) {
  24.  
  25. Die();
  26. }
  27. }
  28.  
  29. void Die() {
  30. Debug.Log ("Dead");
  31. Destroy (this.gameObject);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement