Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // THIS IS THE HEALTH FOR YOUR PLAYER.
- // ATTACH THIS TO YOUR PLAYER.
- using UnityEngine;
- using System.Collections;
- public class BasicHealth : MonoBehaviour {
- public float maxHealth = 60;
- public float curHealth;
- void Start(){
- curHealth = maxHealth;
- }
- // THIS GIVES HEALTH (CHANGE TAKEDAMAGEE) TO WHAT YOU LIKE, JUST BE SURE TO CHANGE THE NAME IN ADD HEALTH SCRIPT.
- public void TakeDamagee(float amt) {
- curHealth += amt;
- }
- // THIS TAKES HEALTH!!
- public void TakeDamage(float amt) {
- curHealth -= amt;
- if(curHealth <= 0) {
- Die();
- }
- }
- void Die() {
- Debug.Log ("Dead");
- Destroy (this.gameObject);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement