NavAgentComponent struct in Thread
A pathfinding agent. The navigation system paths from the entity's position to
Target across the baked NavMesh and writes the
sibling CharacterControllerComponent's
DesiredVelocity to steer along it. Requires a TransformComponent and a
CharacterController on the same entity.
Steering
| Speed | float | Movement speed along the path (m/s). |
| StoppingDistance | float | Stop within this XZ distance of the goal. |
| WaypointRadius | float | Advance to the next waypoint within this distance. |
| RepathInterval | float | Seconds between path recomputes while moving. |
Command & state
| Target | Vec3 | Destination in world space. |
| HasTarget | bool | Set true to start moving; cleared when arrived. |
| Arrived | bool | Runtime read-only — true once within StoppingDistance. |
| Path | std::vector<Vec3> | Runtime waypoint list (not serialized). |
Example (from a script)
void OnUpdate(float ts) override {
auto& agent = GetComponent<Thread::NavAgentComponent>();
agent.Target = m_Player.GetComponent<Thread::TransformComponent>().Translation;
agent.HasTarget = true; // the nav system does the steering
}
For decision logic on top of movement, drive the agent from a BehaviourTreeComponent (its MoveTo task sets Target).
NavAgentComponent struct w Thread
Agent wyszukiwania ścieżek. System nawigacji wyznacza ścieżkę od pozycji encji do
Target po wypieczonym NavMeshu i ustawia
DesiredVelocity sąsiedniego CharacterControllerComponent,
żeby nią podążać. Wymaga TransformComponent i CharacterController na tej samej encji.
Sterowanie
| Speed | float | Prędkość ruchu po ścieżce (m/s). |
| StoppingDistance | float | Zatrzymaj się w tej odległości XZ od celu. |
| WaypointRadius | float | Przejdź do następnego punktu po zbliżeniu się na tę odległość. |
| RepathInterval | float | Sekundy między ponownymi wyliczeniami ścieżki w ruchu. |
Polecenie i stan
| Target | Vec3 | Cel w przestrzeni świata. |
| HasTarget | bool | Ustaw true, żeby ruszyć; czyszczone po dotarciu. |
| Arrived | bool | Tylko do odczytu w czasie działania — true po wejściu w StoppingDistance. |
| Path | std::vector<Vec3> | Lista punktów w czasie działania (nie zapisywana). |
Przykład (ze skryptu)
void OnUpdate(float ts) override {
auto& agent = GetComponent<Thread::NavAgentComponent>();
agent.Target = m_Player.GetComponent<Thread::TransformComponent>().Translation;
agent.HasTarget = true; // sterowaniem zajmie się system nawigacji
}
Logikę decyzji nad ruchem daje BehaviourTreeComponent (jego zadanie MoveTo ustawia Target).