APawn::DisplayDebug
#include "GameFramework/Pawn.h"
Access: public
Specifiers: virtualoverride
Description
Draws pawn-specific debug information to the screen when the ShowDebug command is active. Override to add custom debug text for your pawn subclass.
Caveats & Gotchas
- • Always call Super::DisplayDebug() first so that base pawn and actor info is drawn before your additions — omitting the super call will suppress standard pawn debug output.
- • This function is called every frame while ShowDebug is active and Canvas drawing has measurable cost at high frequency — keep per-frame allocations minimal (avoid FString construction in hot paths).
Signature
ENGINE_API virtual void DisplayDebug(UCanvas* Canvas, const FDebugDisplayInfo& DebugDisplay, float& YL, float& YPos) override; Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Canvas | UCanvas* | Canvas to draw debug text on. | — |
| DebugDisplay | const FDebugDisplayInfo& | Info about which debug categories are active. | — |
| YL | float& | Height of the last drawn text line; updated each call. | — |
| YPos | float& | Current vertical draw position on the canvas; incremented as lines are drawn. | — |
Return Type
void Example
Override to add custom debug info C++
void AMyPawn::DisplayDebug(UCanvas* Canvas, const FDebugDisplayInfo& DebugDisplay, float& YL, float& YPos)
{
Super::DisplayDebug(Canvas, DebugDisplay, YL, YPos);
if (DebugDisplay.IsDisplayOn(TEXT("MyPawn")))
{
FString DebugStr = FString::Printf(TEXT("Health: %.1f"), Health);
Canvas->DrawText(GEngine->GetMediumFont(), DebugStr, 4.f, YPos);
YPos += YL;
}
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?