using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class zombHit : MonoBehaviour
{
public GameObject player;
public float damage;
private void OnTriggerStay(Collider other)
{
Debug.Log("Hitzone ENTERED!");
if (other.gameObject == player)
{
GetComponentInParent<NavMeshAgent>().speed = 0;
GetComponentInParent<Animator>().Play("Attack");
}
}
private void OnTriggerExit(Collider other)
{
if (other.gameObject == player)
{
GetComponentInParent<NavMeshAgent>().speed = GetComponentInParent<EnemyAI>().chasemoveSpeed;
}
}
private void takeDamage()
{
player.GetComponentInParent<Target>().TakeDamage(damage);
}
}
So, I was recommended to using Animation events where when the animation plays it would activate the function take damage. However, instead of the enemy doing damage to the player it is damaging itself. I’m pretty new to using animation event so I’m clueless here despite accessing the players health script that I named “target” for it to do damage to. Moreover, it does not accept the variable given as the damage which I in the inspector had to set it in the animation event bar as a float.