A Simpler Solution, I think

This was my solution for keeping the dead enemies from interfering with raycasts that seems to be working fine, can someone let me know if this will cause any problems in future lessons?

I just disabled the capsule collider, which means that we can’t hit it with our raycast, and then disabled the NavMeshAgent so that the player could run through the dead bodies. Disabling the NavMeshAgent isn’t necessary if you don’t mind kicking the dead bodies around as you run into them. Here is the actual code:

private void Die() 
{
    isDead = true;
    GetComponent<Animator>().SetTrigger("dead");
    GetComponent<CapsuleCollider>().enabled = false;
    GetComponent<NavMeshAgent>().enabled = false;
}
1 Like

Hi Christopher,

I think that’s what the instructor does as well, but I don’t remember having any issues kicking bodies around if their NavMeshAgent was enabled, the issue is that they will still chase you while they are dead (and they can move around in general).

I think Sam addresses some of these in later videos…

The NavMeshAgent won’t cause us to kick bodies around, but the Collider with RigidBody attached will. The NavMeshAgent will, however, prevent us from walking into or through the space occupied by the NavMeshAgent.

1 Like

This topic was automatically closed after 36 hours. New replies are no longer allowed.

Privacy & Terms