Files
Memory-Defense/Assets/Scripts/LivingEntity.cs

24 lines
493 B
C#
Raw Normal View History

using System;
using UnityEngine;
public class LivingEntity : MonoBehaviour
{
public float health;
public void Damage(float amount)
{
health -= amount;
if (health <= 0)
{
Destroy(gameObject);
}
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.layer == LayerMask.NameToLayer("Bullet"))
{
Destroy(gameObject);
other.gameObject.SetActive(false);
}
}
}