RealDocs

APawn::EndViewTarget

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

Description

Called when this pawn stops being the view target of a PlayerController. The APawn override clears the internal flag set by BecomeViewTarget(), so that IsLocallyViewed() correctly returns false.

Caveats & Gotchas

  • Always call Super::EndViewTarget(PC) — the base implementation clears bIsLocalViewTarget; omitting it will cause IsLocallyViewed() to return true indefinitely after the camera has moved away.
  • Paired with BecomeViewTarget(), this is the correct place to undo visual changes made when the camera switched to this pawn (e.g. switching mesh visibility or disabling effects).

Signature

ENGINE_API virtual void EndViewTarget(APlayerController* PC) override;

Parameters

Name Type Description Default
PC APlayerController* The PlayerController that is no longer viewing this pawn.

Return Type

void

Example

Restore third-person mesh when the camera switches away C++
void AMyPawn::EndViewTarget(APlayerController* PC)
{
    Super::EndViewTarget(PC);
    if (PC && PC->IsLocalController())
    {
        FirstPersonMesh->SetVisibility(false);
        ThirdPersonMesh->SetVisibility(true);
    }
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.