Navigation components

BeginnerLevel designerProgrammer

Navigation components allow entities to use navigation meshes to find paths through the scene. Alternatively, if you enable dynamic navigation in Game Settings, entities can generate their own navigation meshes.

Add a navigation component

  • Select an entity you want to use navigation.

  • In the Property Grid, click Add component and select Navigation.

Add navigation component

Game Studio adds a navigation component to the entity.

  • Under the Navigation component properties, next to Navigation mesh, click Hand icon (Select an asset):

Select an asset

The Select an asset window opens.

Choose navigation mesh

Alternatively, if you want this entity to navigate dynamically by generating its own navigation mesh, leave the Navigation mesh field empty. For more information, see Dynamic navigation.

  • Under Group, select the navigation group the entity should belong to. The entity uses the navigation properties you set in this group.

Choose navigation group

Use navigation components in scripts

For example:

  1. void Move(Vector3 from, Vector3 to)
  2. {
  3. var navigationComponent = Entity.Get<NavigationComponent>();
  4. List<Vector3> path = new List<Vector3>();
  5. if(navigationComponent.TryFindPath(from, to, path))
  6. {
  7. // Follow the points in path
  8. }
  9. else
  10. {
  11. // A path couldn't be found using this navigation mesh
  12. }
  13. }

For more information, see the NavigationComponent API documentation.

See also