APawn::BecomeViewTarget
#include "GameFramework/Pawn.h"
Access: public
Specifiers: virtualoverride
Description
Called when this pawn becomes the view target of a PlayerController. The APawn override sets an internal flag used by IsLocallyViewed() to enable VFX optimisations for the viewed pawn.
Caveats & Gotchas
- • Always call Super::BecomeViewTarget(PC) in your override — the base APawn implementation sets the bIsLocalViewTarget flag which is queried by IsLocallyViewed(); skipping it will cause IsLocallyViewed() to return incorrect results.
- • This is called on the local machine only — it fires when the PlayerController's camera view switches to this pawn, not when the pawn is just visible on screen.
Signature
ENGINE_API virtual void BecomeViewTarget(APlayerController* PC) override; Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| PC | APlayerController* | The PlayerController that is now viewing this pawn. | — |
Return Type
void Example
Override to enable first-person mesh when the camera switches to this pawn C++
void AMyPawn::BecomeViewTarget(APlayerController* PC)
{
Super::BecomeViewTarget(PC);
if (PC && PC->IsLocalController())
{
FirstPersonMesh->SetVisibility(true);
ThirdPersonMesh->SetVisibility(false);
}
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?