check for collision not responsive in scripting?

I have a character do an animation of attack with a sword. and I have it so on collision of sword will do damage. Sometimes it is not responsive, where would be the problem in the scripting or animation? (I am using fixed update)

sounds like you might be using A mesh collider…?

if so change to box collider might give better results?

Yeah, make sure you’re using primitive colliders, for the weapon at the very least.

Also, turn on continuous and/or dynamic collision detection. By default, collisions are only detected on each frame, and anything that might happen between frames is ignored. That’s ok most of the time, but there are some situations where you need it to be a little more diligent, and this could be one of those cases (depending on how your weapons work).

I’m not sure if that setting needs to be enabled on just one collider in the collision, or both. Check the documentation, it should point you in the right direction.

Another way to do collision detection for attacks is to do it separately to the animation. Create an “attack” collider as a trigger, attach it to the front of your character, and when you want to deal damage simply apply it to anything currently touching that collider. It’s not as accurate, but that usually doesn’t matter, and it makes your gameplay easier to fine-tune later without having to mess with your animations. For instance, if different weapons are intended to have different ranges or arcs, you then only have to scale that collider accordingly. If you’ve got enemies that are low to the ground you can also just stretch it instead of making special attack animations that reach downward. And you can stick to generic colliders for your enemies and make life easier for yourself in a bunch of different ways associated with that.