AActor::DisplayDebug
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtual
Description
Called by the HUD to draw debug information for this actor on-screen when the `showdebug` console command is active. Override to display custom actor variables.
Caveats & Gotchas
- • Always call `Super::DisplayDebug()` first so base class info (physics, collision) is still drawn. Failing to do so means the standard debug output is silently suppressed.
- • This function is only called when this actor is the current ViewTarget and a matching debug category is active. It is not called in Shipping builds — guard any heavy logic with `#if !UE_BUILD_SHIPPING`.
Signature
ENGINE_API virtual void DisplayDebug(class UCanvas* Canvas, const class FDebugDisplayInfo& DebugDisplay, float& YL, float& YPos) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Canvas | class UCanvas* | Canvas to draw on. | — |
| DebugDisplay | const class FDebugDisplayInfo& | Contains information about which debug categories are currently active. | — |
| YL | float& | In: height of the previously drawn line. Out: height of the last line drawn by this function. | — |
| YPos | float& | In: Y position for the previous line. Out: Y position after the last line drawn. | — |
Return Type
void Example
Draw custom health info in showdebug C++
void AMyCharacter::DisplayDebug(UCanvas* Canvas, const FDebugDisplayInfo& DebugDisplay, float& YL, float& YPos)
{
Super::DisplayDebug(Canvas, DebugDisplay, YL, YPos);
FString HealthStr = FString::Printf(TEXT("Health: %.1f / %.1f"), Health, MaxHealth);
Canvas->SetDrawColor(FColor::Green);
Canvas->DrawText(GEngine->GetSmallFont(), HealthStr, 4.0f, YPos);
YPos += YL;
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?