RealDocs

AActor::PostRenderFor

function Engine Since unknown
#include "GameFramework/Actor.h"
Access: public Specifiers: virtual

Description

Hook for actors to render HUD overlays for themselves, called from AHUD::DrawActorOverlays(). Override to draw world-space or screen-space debug/gameplay UI attached to this actor.

Caveats & Gotchas

  • Only called on the local client — not executed server-side — so any drawing here is purely cosmetic and per-player.
  • This function is only invoked if the actor has registered itself with the HUD via AHUD::AddPostRenderedActor; the actor must actively opt-in to be iterated by DrawActorOverlays.
  • Canvas drawing operations here use immediate-mode rendering; do not cache Canvas state across frames as the Canvas pointer may change between calls.

Signature

ENGINE_API virtual void PostRenderFor(class APlayerController* PC, class UCanvas* Canvas, FVector CameraPosition, FVector CameraDir)

Parameters

Name Type Description Default
PC class APlayerController* The player controller whose HUD is rendering the overlay.
Canvas class UCanvas* The canvas to draw on.
CameraPosition FVector World position of the camera rendering this overlay.
CameraDir FVector World direction the camera is pointing.

Return Type

void

Example

Draw a name tag above an actor in world space C++
void AMyInteractable::PostRenderFor(APlayerController* PC, UCanvas* Canvas, FVector CameraPosition, FVector CameraDir)
{
    if (!Canvas || !PC) return;

    FVector WorldPos = GetActorLocation() + FVector(0, 0, 100.f);
    FVector ScreenPos = Canvas->Project(WorldPos);
    Canvas->SetDrawColor(FColor::White);
    Canvas->DrawText(GEngine->GetSmallFont(), GetName(), ScreenPos.X, ScreenPos.Y);
}

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.