BT LookAt - choosing between the stock task and the LCM Nav3D one
TL;DR: Unreal Engine ships
UBTTask_RotateToFaceBBEntry, and for a ground agent it is the
right answer. For a flying agent it is not, because both its success test
and its applied rotation ignore the vertical axis. LCM Nav3D now ships
LCM_BTTask_LookAt and LCM_BTTask_TurnInPlace for
that case.
Which one to use
| Situation | Use |
|---|---|
| Ground agent, target roughly level with it | Stock UBTTask_RotateToFaceBBEntry |
| You want facing to persist across several tasks | Stock task plus UBTService_DefaultFocus |
| Target can be above or below the agent | LCM_BTTask_LookAt |
| You need a constant turn rate rather than an eased one | LCM_BTTask_TurnInPlace |
| You need the turn to hold position while it happens | Either LCM task, with bHoldStation |
The stock task, and what it does with the vertical axis
The stock task is well suited to walking agents and integrates with the AIController focus system, which is why it is the default recommendation in most UE projects. Two details matter once the agent can fly.
Its success test is two dimensional. The task measures
alignment with FVector::CosineAngle2D, which projects both
directions onto the XY plane before comparing them. A target directly above
the agent therefore has an angle difference of zero: the task reports
success immediately, with the agent still pointing level.
Its applied rotation drops pitch by default. The task
rotates the pawn through the controller focus system, and
APawn::FaceRotation keeps the pawn's existing pitch unless
bUseControllerRotationPitch is set. On a default pawn that
flag is false.
Together those mean that, for a target overhead, the stock task can neither point the agent at it nor notice that it has not.
None of this is a defect in the stock task. It is built for agents that move on a surface, where yaw is the only axis that matters.
The LCM Nav3D tasks
LCM_BTTask_LookAt eases toward the target;
LCM_BTTask_TurnInPlace turns at a constant rate. They are
otherwise the same node with a different rate mode, and both:
- measure the real 3D angle between the agent's forward vector and the target direction, so a pure pitch error reads as a pitch error;
- apply pitch as well as yaw;
- optionally hold position during the turn (
bHoldStation), so a body with momentum does not drift while it rotates; - optionally require line of sight, and wait rather than fail while navigation data is still streaming in.
Property lists are in the API Reference.
Pattern: face a target, then act
Sequence
LCM LookAt (TargetKey = ThreatActor)
<your attack task>
bFailOnTimeout defaults to false, so a turn that runs out
of time still succeeds and the sequence continues. Set it true if a failed
turn should abort the sequence.
Pattern: keep facing while doing other things
This is still the stock pattern and LCM Nav3D does not replace it:
- Add
UBTService_DefaultFocusto the parent Selector or Sequence. - Set its focus blackboard key.
- The controller holds focus for the whole subtree.
⚠ Do not run a focus service and a rotation task at the same time. The AIController re-asserts focus rotation every tick, so it will fight any task that writes rotation itself, including the LCM tasks. Pick one: a focus service for continuous facing, or a rotation task for a discrete turn. Running both has been observed to stall the agent outright.
On 6-DOF flight bodies
If the pawn carries LcmFlightMovementComponent with the
flight dynamics locomotion model, that component owns the body's
orientation and derives it from its own dynamics every tick. A rotation
written by any task, stock or LCM, is overwritten in the same frame.
The LCM tasks detect this and report the facing as unsupported rather than pretending to have turned; the task still succeeds so that a sequence containing it continues to work. Agents using the default kinematic locomotion model are unaffected and rotate normally.
See also
LCM_BTTask_MoveToAndFace- travel to a point and turn to face something on arrival, as one task.LCM_BTTask_Hover- hold position while facing a target, for a fixed time or indefinitely.