So, I need to make a damage to an enemy after player touches ENEMY with his fists or weapon(in my game I can change weapons, like swords and etc.)
It is really cool with enemies: I get damage after animation event and they attack me when I am close and I die after while.
But I can’t do same with player, player attacks, animation event is working but I can’t make any damage(make HP go to zero).
How to make animation collider(if it exists), how to damage enemies with animations?
relevant parts of code:
private void Attackin()
{
if (Input.GetButtonDown("Fire1"))
{
StartCoroutine("playerAttackAnim");
}
}
void Hit()//animation event
{
Debug.Log("Player attack is working");
if (enemyHealth == null) { Debug.Log("No Enemy Detected"); return; }
//it is working
enemyHealth.TakeDamage(gameObject, damage);//not working against enemies
}
Get Damage(Health script):
public void TakeDamage(GameObject instigator,float damage)
{
Debug.Log(gameObject.name + "took " + damage + " Damage");
healthPoints = Mathf.Max(healthPoints - damage, 0);
if(healthPoints <= 0)
{
Die();
}
}