How i prevent 2 obejcts with kinematic checked in both rigidbodies collide?

I have this AI in enemies that goes to the player, i want to avoid that 2 objects collide (both of them are with kinematic checked in their rigidbodies). I need this because of the animations (they slide at the transition if kinematic is not checked) and i am using navmeshagent for the AI movement.

I went to Physics and disabled the layers collision but it not worked.

There is a workaround?

When moving a Kinematic Rigidbody, either through its transforms, or preferably with Rigidbody.MovePosition(), you need to check for collisions yourself, as Kinematic Rigidbodies will

  1. not be applied any force (gravity, nor forces),
  2. not suffer collisions, although other Rigidbodies will collide with them like they had an infinite mass.

You can simply use Physics.RayCast(), or better use Physics.BoxCast(), or Physics.SphereCast() to detect possible collisions on the way.

Something like this :

void FixedUpdate ()
{
    // if nothing is in the way along 1 unit ahead
    if (!Physics.RayCast (transform.position, transform.forward, 1f)
    {
        // move rigidbody 0.5f forward
        rigidbody.MovePosition (rigidbody.position + transform.forward * 0.5f);
    }
}

I’m using NavMesh to the movement. I made some tests and even with kinematic unchecked they are still colliding.

I see. But the real problem is that i’m spawning obejects as enemies, like an gropu of similar enemies. They have to go to a certain position to attack my player. But they collide with each other.

Try to Change Collision Layers on Collision Matrix Edit > projectSettings > Physics

I made 2 videos to show what is happening. The video with 1 enemy is the way i want. The video with the 2 enemies is whats happening they keep pushing each other.