APawn::GetPawnViewLocation
#include "GameFramework/Pawn.h"
Access: public
Specifiers: virtualconst
Description
Returns the world-space location of the pawn's eyes, offset upward from the collision center by BaseEyeHeight. Use this as the origin for weapon traces, projectile spawning, or any logic that should originate from where the character 'sees'.
Caveats & Gotchas
- • The base implementation simply returns GetActorLocation() + FVector(0,0,BaseEyeHeight) — it does NOT account for crouching. ACharacter overrides this and adjusts for crouch state.
- • For multiplayer traces, prefer GetActorEyesViewPoint() over calling this and GetViewRotation() separately, as the former is a single virtual call and is already used by engine sight checks.
Signature
virtual FVector GetPawnViewLocation() const Return Type
FVector Example
Weapon line trace from eyes C++
FVector EyeLocation = GetPawnViewLocation();
FRotator EyeRotation = GetViewRotation();
FVector TraceEnd = EyeLocation + EyeRotation.Vector() * 10000.f;
FHitResult HitResult;
GetWorld()->LineTraceSingleByChannel(HitResult, EyeLocation, TraceEnd, ECC_Visibility); Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?