2.0 Help

AI Navigation Component

The AI navigation component is used to make an NPC move towards a destination, using the navmesh to move around obstacles.

The component has to be instructed via code what to do. The SetDestination() function is used to make it move the parent game object along a path towards the goal. GetState() can be called to query whether it is moving and how.

The component uses physics queries to place the NPC on solid ground. It uses the navmesh information only for the general direction. The foot radius determines the width for this query. It should be wide enough, so that the NPC cannot fall through small holes in the ground, but narrow enough, so that it can't stand far away in the air on a ledge. As long as the "feet" touch any solid ground, the NPC will hang there, it will not slide down.

This component demonstrates how navigation for an NPC can be implemented. It is not meant to be a solution for every game, though. In many cases you may want to implement your own, so that you can handle your game specific needs as desired. Don't hesitate to copy the implementation of this component and just use it as a starting point.

Component Properties

  • Navmesh Config: Which navmesh type to do the search on.

  • Path Search Config: Which path search type to use for the path search.

  • Speed: The target speed to reach.

  • Acceleration, Deceleration: How quickly to accelerate and decelerate.

  • Foot Radius: The footprint to determine whether the character is standing on solid ground.

  • Reached Distance: The distance at which the destination is considered to be reached.

  • Collision Layer: The physics collision layer for determining what ground one can stand on.

  • Fall Height: If there is more distance below the character than this, it is considered to be falling.

  • Debug Flags: What aspects of the navigation to visualize.

See Also

Last modified: 16 August 2024