So, I’m playing around with an attempt at a combat system and ran into something that seems odd.
I have a little guy that stabs with a spear when an enemy is in the path the spear would travel. It detects an enemy with a trigger collider in the spear’s path, and when that’s triggered, an animation moves the spear down that path, and my hope was that a collider on the spear could then register the hit, but it doesn’t look like it does. The OnCollisionEnter method is never called. Both the spear and the target have kinematic rigid bodies and box colliders.
I’m considering a workaround like having the hit automatically register if the target is still in the spear’s path when it gets to a certain keyframe in the animation, but I’d really rather register the hit with collision detection.
I’m pretty sure the events are wired up correctly because if I just place the spear in an extended position and have the guy run forward toward the target (with the stabbing animation disabled) that does register a hit. So I suspect it has to do with moving the spear with an animation.
Is this possible? Am I coming at it from the wrong angle?
Edit: I put together a small self-contained repro of what I’m doing and what I’m seeing. This project has two cubes with colliders and rigid bodies, and an animation moves one into the other. There’s a script on the one being animated that logs calls to OnCollisionEnter out to the console. I get no log messages: https://drive.google.com/open?id=1oljWz-TZI43mTOB9B6kp2luLw11K9-uz (I would have attached, but it’s over the size limit.)