NavAgent
Walks this node to its Target by the cheapest way the Nav Region under it allows: round walls and obstacles, across links. A Character Body is moved by its velocity, so walls still hold; a node without one is moved directly.
On this page
Add it
+ Add node → Nav Agent creates a node with it already on. Already have a node for it? Add component → NavAgentComponent.
From a script
A script on the same node writes these fields by name. NavAgentComponent is the name to pass.
rgs
set_point("NavAgentComponent", "target", vec2(0.0, 0.0));
set_flag("NavAgentComponent", "moving", false);
set_number("NavAgentComponent", "speed", 80.0);
set_number("NavAgentComponent", "arrive_distance", 4.0);
set_flag("NavAgentComponent", "face_walk", false);
set_flag("NavAgentComponent", "use_links", true); Fields
| Field | Script name | Kind | Default | What it does |
|---|---|---|---|---|
| Target | target | two numbers (x, y) | (0, 0) | Where it walks to, in the world. |
| Moving | moving | checkbox | off | Whether it is walking to its Target now; it turns off when it arrives or finds no way there. |
| Speed | speed | number, at least 0 | 80 | How fast it walks, in world units a second. |
| Arrive Distance | arrive_distance | number, at least 0.5 | 4 | How near its Target counts as there. |
| Face Walk | face_walk | checkbox | off | Mirrors this node's Sprite to face left while it walks left. |
| Use Links | use_links | checkbox | on | Whether its way may cross Nav Links: ladders, drops and teleports. |