Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class PlayerHealth : MonoBehaviour
- {
- public int maxHealth = 100;
- private int currentHealth;
- void Start() => currentHealth = maxHealth;
- public void TakeDamage(int amount)
- {
- currentHealth -= amount;
- Debug.Log("Player took damage. Current Health: " + currentHealth);
- if (currentHealth <= 0)
- {
- Die();
- }
- }
- void Die()
- {
- Debug.Log("Player Died.");
- // Add death logic
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment