I have a trigger attached to character hand to act as an attack box, and recently noticed the OnTriggerEnter sometimes not reacting to enemy colliders. Already tried most popular solutions: increased fixed timestamp (up to 0.001), added rigidbody (with Continuous Dynamic collision detection), and reduced animation speed - still no signs of improvement.
Even tried to replace trigger with OverlapSphere, but result is the same, even when I did OverlapSphere check with “InvokeRepeating” with repeat rate 0.001s.
Colliders are not small - 1 in radius and 10 in height for attack box and 2 and 8 for an enemy, so it’s hard to believe that the issue’s in size.
Do I still miss something, or it’s some common unity issue I did not hear about?
Have you tried attatching a RigidBody with Continuous detection mode (Not continuous dynamic) to the objects that are supposed to be hit by the sword?
I have once fiddled with this issue and found out that I could put a bullet (or many) travelling at the speed of light (exagerating a bit but you get the ideia) and it still detected the collision, but setting the rigidbody on the bullet as Continuous Dynamic, and objects that slow or static, with Continuous. It worked flawlessly.
If the fast moving object is being moved by an Animator and not a Rigidbody, make sure you set the Update Mode of the Animator to “Animate Physics”
I had a similar issue in the past when adding a collider to a swinging sword to deal damage. I think collision detection in this case is not fully trustworthy; and trying to patch it didn’t really help.
Instead, I’d suggest you send an event at a specific point (or several points) during your attack animation through code. If an enemy is within range when this event is sent, then they’ll take damage.
This way you don’t need colliders and will get more predictable results.