Tutorial 13 - LCM Fly To Location (no Behavior Tree, no StateTree)
TL;DR: LCM Fly To Location is the
flying counterpart of the engine's AI Move To node.
Call it from any Blueprint - a level script, a pawn's Event Graph, a
widget - with a pawn and a destination, and it fires On
Success when the pawn arrives or On Fail with
the reason it did not. The pawn needs no AI Controller, no Behavior Tree
and no StateTree.
What you need
- An LCM Nav3D Manager in the level, with navigation data built or baked (as for any agent).
- A pawn. Either kind works:
- With an enabled LCM Flight Movement Component, the pawn flies with its 6-DOF dynamics - banking, braking, a fish's tail - exactly as it does under the Fly To tasks. The component's Agent Scale carries over, so a fish at 0.08 uses its own acceptance, speeds and clearances.
- Without one, the pawn is moved kinematically at Flight Speed.
Using the node
- Right-click in a Blueprint graph and search for LCM Fly To Location (category LCM Nav3D | Movement).
- Connect Pawn and Destination.
- Handle the two exec pins:
- On Success - the pawn has arrived.
- On Fail - it has not; the Result pin says why.
Both pins also give Pawn Location, where the pawn was when the request ended.
| Input | Default | Meaning |
|---|---|---|
| Pawn | - | The pawn to fly. |
| Destination | - | Where to go. Ignored when Target Actor is set. |
| Target Actor | none | Fly to this actor instead, re-planning as it moves. |
| Acceptance Radius | -1 | Arrival distance in cm. <= 0 uses the Fly To default (100 cm, times the agent scale). |
| Filter Class (advanced) | none | A navigation query filter: which cost areas this pawn avoids or prefers (Tutorial 10). |
| Chase Moving Target (advanced) | off | Aim where a moving Target Actor is going, not where it is. |
| Flight Speed (advanced) | -1 | Kinematic pawns only: cruise speed in cm/s. <= 0 uses the default. |
| Timeout Seconds (advanced) | 0 | Give up after this long. <= 0: no limit. |
| Result | Pin | When |
|---|---|---|
| Success | On Success | Arrived. |
| No Path | On Fail | The destination cannot be reached from where the pawn is: sealed, outside the navigable volume, or excluded by the filter. |
| Failed | On Fail | The pawn set off but could not complete the route. |
| Aborted | On Fail | Cancelled, stopped, or replaced by a newer request for the same pawn. |
| Timed Out | On Fail | Ran longer than Timeout Seconds. |
| Invalid Request | On Fail | No pawn, or no LCM Nav3D Manager in the pawn's world. Fires at once. |
Stopping and replacing
- One request per pawn. A new
LCM Fly To Locationon a pawn that is already flying ends the old one with Aborted and takes over, as AI Move To does. - Cancel (on the node's return value) or Stop LCM Fly To (on the pawn) ends the request with Aborted.
- Is LCM Fly To Active tells you whether a pawn is flying one.
A stopped 6-DOF pawn holds where it was stopped rather than cruising on its last command. A body that cannot stop dead - a fish, a bird - glides its stopping distance and comes back. Measured on the demo fish: at most 4-7 cm past the cancel point, and settled within 2 cm of it 4 s later.
How arrival is judged
- A pawn arrives within Acceptance Radius of the destination. If the body reaches its last waypoint's neighbourhood and cannot close the final gap, it settles and completes within twice the radius. This is the Fly To tasks' rule.
- With a Target Actor, the pawn must reach the actor. With Chase Moving Target on, the pawn steers at a predicted intercept point, but reaching that point does not count as arriving; it keeps flying until it is within range of the actor itself.
- A path that is still being computed, or a streaming gap in an infinite world, is not a failure. The request waits.
- The request pauses with the game.
One Fly To, not three
The node has no movement code of its own. It runs the StateTree Fly To task's own code - the same planner, cost areas, re-planning, streaming waits, avoidance, speed governor, arrival and flight-component hand-off. A pawn flies the same whether a tree or this node sends it.
Do not drive one pawn from two places at once. A
pawn running a Fly To task in a Behavior Tree or StateTree and an
LCM Fly To Location at the same time has two sources of
guidance; the last one each frame wins. Stop the tree's task (or leave
the pawn without a tree) before using the node on it.
From C++
#include "Agent/LCM_FlyToAsyncAction.h"
ULcmFlyToLocationAsyncAction* Fly = ULcmFlyToLocationAsyncAction::FlyToLocation(
this, MyPawn, FVector(4500, -2000, 800));
Fly->OnSuccess.AddDynamic(this, &AMyActor::HandleArrived); // UFUNCTION(ELcmFlyToResult, FVector)
Fly->OnFail.AddDynamic(this, &AMyActor::HandleNotArrived);
Fly->Activate();
In C++, bind the delegates before calling
Activate(): an invalid request fires On Fail inside
Activate(). The Blueprint node does this for you.
Verified
The battery gate g35_flyto_node
(-run=LcmNavCostTest -Group=FlyToNode) flies a pawn with no
controller through the demo fish tank at a 1 cm leaf and the stock
navigator pawn across the metre-scale cost showcase. It checks every
case above: an invalid request, arrival and a single On Success, never
inside rock or glass, No Path, replacement, Cancel and hold, a chase to
a moving actor.