APawn::GetNavAgentPropertiesRef
#include "GameFramework/Pawn.h"
Access: public
Specifiers: virtualoverride
Description
Returns the nav agent properties (agent radius, height, step height, etc.) used by the navigation system to query the correct navmesh for this pawn. Delegates to the movement component's NavAgentProps when one is present.
Caveats & Gotchas
- • Returns a reference to the movement component's internal FNavAgentProperties struct. If the movement component is destroyed mid-frame the reference becomes dangling — do not cache it across frames.
- • If the pawn has no movement component, the function falls back to a default-constructed FNavAgentProperties, which has zero radius and height — meaning the pawn will use the default (unconstrained) agent query. This can produce unexpected navmesh query results for pawns without a movement component.
Signature
virtual const FNavAgentProperties& GetNavAgentPropertiesRef() const override Return Type
const FNavAgentProperties& Example
Read agent radius for a custom nav query C++
void AMyAIController::BuildPathfindingQuery()
{
if (APawn* P = GetPawn())
{
const FNavAgentProperties& Props = P->GetNavAgentPropertiesRef();
UE_LOG(LogTemp, Log, TEXT("Agent radius: %.1f, height: %.1f"),
Props.AgentRadius, Props.AgentHeight);
}
} Tags
Version History
Introduced in: 4.6
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?