Scriptum/Assets/Scripts/Enemies' Scprits/Enemy.cs

27 lines
512 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour
{
public float moveSpeed;
public string enemyName;
2022-05-18 13:58:41 +02:00
public FloatValue maxHealth;
public float health;
2022-05-18 13:58:41 +02:00
private void Awake()
{
2022-05-18 13:58:41 +02:00
health = maxHealth.initialValue;
}
2022-05-26 13:30:59 +02:00
private void TakeDamage(float damage)
{
2022-05-18 13:58:41 +02:00
health -= damage;
2022-05-26 13:30:59 +02:00
if (health <= 0)
2022-05-18 13:58:41 +02:00
{
this.gameObject.SetActive(false);
}
2022-05-26 13:30:59 +02:00
}
2022-05-18 13:58:41 +02:00
}