I'm trying to make a melee attack so I put rigidbodies(iskinematic) to object and sword. I also added coliders but the problem is sword may touch the collider when the character moves a bit without waiting my hit command. What can i add to my code to wait for the animation to finish? Here is my code:
using UnityEngine;
using System.Collections;
public class Health : MonoBehaviour
{
public float health;
void Start()
{
health = 100;
}
void Update ()
{
if (health < 0)
{
Destroy(this.gameObject);
}
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Weapon")
{
health -= 10;
}
}
}
↧