I am trying to get some melee combat working; in this case I have a character (3rd person) with various attack animations. One or two of these animations seems to be too fast for the system, here is what I have done.
The character has a sword equipped (with a collider on the blade). When the character attacks an attack animation is triggered, when the animation reaches a certain point an AnimationEvent is fired (this event just sets a bool used to determine if the collision should be handled or not - used to avoid attacking an enemy when walking into one for example).
This works well, most of the time! But what I am experiencing is that once in a while the sword passes through the target without hitting, but then it hits on the return trip (by that I mean that the animation pulls the sword back to the ready stance after swinging, and this drags the blade (and hence the collider) through the target and triggers the hit).
So in short it seems that the sword passes through the enemy collider sometimes too fast (it is a fast attack). This is also something I have seen others mention that perhaps the animation is so fast that the position of the blade skips such a distance that at one frame it is “to one side of the enemy collider” and the next frame it is “on the other side of the enemy collider”?
In any case, I have tried to slow the animation and increase the enemy collider size, both seems to do the trick, however I would like to hear if there is a better solution for this “issue” and if it is indeed happening because the attack animation is too “fast paced”.
Also would I be better off dropping the collider approach and instead make an AnimationEvent at the point where the sword is supposed to “hit” and then do a RayCast in this event to check if an enemy is close enough and handle the hit here.
I hope it makes sense to someone!!!