using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DamageEnemy : MonoBehaviour
{
// Start is called before the first frame update
[SerializeField] int EnemyHealth = 100;
private AudioSource MyPlayer;
[SerializeField] AudioSource StabPlayer;
private bool HasDied = false;
private Animator Anim;
void Start()
{
MyPlayer = GetComponent();
Anim.GetComponentInParent();
}
// Update is called once per frame
void Update()
{
if (EnemyHealth <= 0)
{
Debug.Log("hahahahah");
if (HasDied == false)
{
Anim.SetTrigger("Death");
HasDied = true;
}
}
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Axe"))
{
EnemyHealth -= 50;
MyPlayer.Play();
StabPlayer.Play();
}
}
}
.........
@LatchGameDev
↧