0
\$\begingroup\$

I can't find any information on this topic. I'm wondering about the differences between the collision detection approach for player as opposed to npcs.

Basically NPCs will move strictly along the navigation mesh (constructed for static environment) with a pathfinding algorithm. And should in theory not collide with any static obstacles. In that case do we really need to check for collision against the static environment?

As opposed to NPCs, players are not bounded by navigation mesh. So we would definitely have to handle collision with static environment.

I'm wondering what the general consensus is around this in game development?

\$\endgroup\$
3
  • \$\begingroup\$ It sounds like you've reasoned this out for yourself. If in your game NPCs move only by their own navigation and can never leave the navmesh (eg. they can't be hurled by an explosion), then in your game navmesh alone would suffice, would it not? Don't rely on "general consensus" — it's a pretty worthless concept in game development where we're all working on vastly different games with unrelated needs. If this works for your game, use it — you do not need the blessing of strangers to do what works for you. \$\endgroup\$
    – DMGregory
    Commented Sep 30, 2020 at 9:31
  • \$\begingroup\$ @DMGregory I don't completely agree. I don't want to reinvent the wheel if there's a generally accepted way to do something. I may go with an idea that seems promising at first, but turn out to have many shortcoming I didn't see right away. That's why I would rather listen to people who have had experience in doing something similar. \$\endgroup\$
    – user134288
    Commented Sep 30, 2020 at 9:57
  • \$\begingroup\$ I haven't thought at all that the npcs may get pushed out of navigation mesh by explosion or other forces. Thanks for the suggestion! So I guess in that case I would definitely need collision check with static environment for npcs. And otherwise could go without it. \$\endgroup\$
    – user134288
    Commented Sep 30, 2020 at 10:04

2 Answers 2

0
\$\begingroup\$

Summarizing my comment above:

You can forego collision-checking/handling between NPCs and static geometry if and only if NPCs can never leave the navmesh.

If an external force can throw NPCs off the navmesh, then they could potentially get into a situation where they'd collide with static geometry outside the navmesh area.

In some games this can cause a glitch where an NPC knocked back by a dynamic collision or explosion becomes stranded and can't find their way back to the navmesh, or just passes straight through the static objects entirely and falls out of the level.

If this can happen in your game, you may want to enable collision-checking anytime something pushes or ragdolls an NPC, and then disable it again once the NPC is safely back in control of their motion on the navmesh.

If you have no outside forces or other influences that can push NPCs off the mesh, or you enforce the navmesh bounds in such a way that they override these other influences, then you may be safe skipping static collision checks with them entirely.

\$\endgroup\$
0
\$\begingroup\$

In many games, the player is in fact following the navmesh. The player says the direction they would like to go and the character agent determines whether or not it is possible. This is much less computationally heavy than calculating collisions with the static environment. By following the navmesh, the NPCs are also able to move where the player can.

\$\endgroup\$

You must log in to answer this question.