RealDocs

APlayerController::GetViewTarget

function Engine Since 4.0
#include "GameFramework/PlayerController.h"
Access: public Specifiers: virtualoverride

Description

Returns the actor the player's camera is currently targeting. Normally this is the possessed pawn, but it can differ when using `SetViewTargetWithBlend` or a camera cut. The camera manager uses this to determine placement and orientation.

Signature

virtual AActor* GetViewTarget() const override

Return Type

AActor*

Caveats & Gotchas

  • The view target is managed by `APlayerCameraManager`; this call queries it.
  • During camera blends, returns the current primary target, not the blend-to target.
  • Returns `nullptr` if no view target is set, which is rare in normal gameplay.

Example

Get the camera's focus point C++
AActor* Target = PlayerController->GetViewTarget();
if (Target)
{
    FVector CamPos = Target->GetActorLocation();
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable
5.0 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.