Advertisement
Sebsebeleb

Player.cs

Jan 21st, 2022 (edited)
1,143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.40 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class Player : MonoBehaviour, ICollision, IHealth
  4. {
  5.     public float Health;
  6.    
  7.     public void TakeDamage()
  8.     {
  9.         Health -= 1;
  10.  
  11.         if (Health <= 0)
  12.         {
  13.             Die();
  14.         }
  15.            
  16.     }
  17.    
  18.     public void Die()
  19.     {
  20.         Destroy(gameObject);
  21.     }
  22.  
  23.     public void Collided()
  24.     {
  25.         TakeDamage();
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement