Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

使用 NavigationAgent

NavigationAgent 即导航代理,是一种辅助节点,能够为继承自 Node2D/3D 的父节点提供寻路、路径跟随、代理躲避等功能。这类节点会代替父级角色节点对 NavigationServer API 进行常见的调用,针对初学者提供便利。

2D 和 3D 版本的 NavigationAgent 分别是 NavigationAgent2DNavigationAgent3D

新建的 NavigationAgent 节点会自动加入 World2D/World3D 的默认导航地图。

NavigationAgent 节点是可选的,不是使用导航系统的硬性要求。它的所有功能都可以用脚本代替,替换为对 NavigationServer API 的直接调用。

小技巧

有关更高级的用法,比起 NavigationAgent 可改用使用 NavigationPathQueryObjects