Why Do Raycasts Ignore NavMesh Agents

I built a simple game using Unity’s built in NavMesh Ageant AI system. My player has a laser that uses a raycast to apply a force to the enemy to not it back. This works… for the first couple seconds of the game. Then, it is as if the NavMesh Agent gets “locked” into movement and is no longer effected by the raycast. I have found a few (very small number) other questions on UA, but none have answers that apply to my situation. Is this a bug in Unity? Or Am I missing some aspect of NavMesh Agents.

I believe I have a solution to the problem. I believe the problem occurs when you have both a navmesh agent on the object as well as a rigidbody. Remove the rigidbody and it should work fine.

I realize this is years after the fact, but I was having this same problem. The only thing that was fixing it was what Meatlof4 said about removing the rigidbody, but then that made the navigation wonky. So what I did that seemed to fix it was I changed the Collision Detection on the rigidbody component from ‘Discrete’, to ‘Continuous’ instead. That seemed to fix it.

Hey, I know this is a really old post. But I had this issue and fixed it by setting the rigidbody as kinematic.

I was trying to get a ragdoll to work so I used:

Rigidbody[] rigidbodys = GetComponentsInChildren<Rigidbody>();
foreach (Rigidbody rigidbody in rigidbodys)
     rigidbody.isKinematic = true;

Try replacing the BoxCollider on your object with a MeshCollider.

This is probably due to mesh sort order; RaycastAll() will also work.

Changing from discrete to continuous does not solve the issue. Rigidbody still needs to be removed.