Working on lession 29
This commit is contained in:
23
Assets/Scripts/EnemyHealthController.cs
Normal file
23
Assets/Scripts/EnemyHealthController.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class EnemyHealthController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] float totalHealth;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
public void TakeDamage(float damageToTake)
|
||||
{
|
||||
totalHealth -= damageToTake;
|
||||
if(totalHealth <= 0)
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user