AHUD

Base class of the heads-up display.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/GameFramework/HUD.h

Include

#include "GameFramework/HUD.h"

Syntax

class AHUD : public AActor

Remarks

Base class of the heads-up display. This has a canvas and a debug canvas on which primitives can be drawn. It also contains a list of simple hit boxes that can be used for simple item click detection. A method of rendering debug text is also included. Provides some simple methods for rendering text, textures, rectangles and materials which can also be accessed from blueprints.

Variables

Name Description

Public variable

uint8: 1

 

bEnableDebugTextShadow

Put shadow on debug strings

Public variable

uint8: 1

 

bLostFocusPaused

Tells whether the game was paused due to lost focus

Public variable

uint8: 1

 

bShowDebugInfo

If true, current ViewTarget shows debug information using its DisplayDebug().

Public variable

uint8: 1

 

bShowHitBoxDebugInfo

If true, show hitbox debugging info.

Public variable

uint8: 1

 

bShowHUD

Whether or not the HUD should be drawn.

Public variable

uint8: 1

 

bShowOverlays

If true, render actor overlays.

Protected variable

UCanvas *

 

Canvas

Canvas to Draw HUD on.

Public variable

int32

 

CurrentTargetIndex

Current target in our considered Targets list for 'showdebug'

Protected variable

UCanvas *

 

DebugCanvas

'Foreground' debug canvas, will draw in front of SlateUI.

Public variable

TArray< FName >

 

DebugDisplay

Array of names specifying what debug info to display for viewtarget actor.

Protected variable

TArray< struct ...

 

DebugTextList

Public variable

TSet< FName >

 

HitBoxesOver

Set of hitbox (by name) that are currently moused over or have a touch contacting them

Public variable

TArray< FHUDHit...

 

HitBoxHits

Array of hitboxes that have been hit for this frame.

Public variable

TArray< FHUDHit...

 

HitBoxMap

Array of hitboxes for this frame.

Public variable

float

 

LastHUDRenderTime

Used to calculate delta time between HUD rendering.

Public variable

APlayerControll...

 

PlayerOwner

PlayerController which owns this HUD.

Public variable

TArray< AActor ...

 

PostRenderedActors

Holds a list of Actors that need PostRender() calls.

Public variable

float

 

RenderDelta

Time since last HUD render.

Protected variable

AActor *

 

ShowDebugTargetActor

Show Debug Actor used if 'bShowDebugForReticleTarget' is true, only updated if trace from reticle hit a new Actor of class 'ShowDebugTargetDesiredClass'

Protected variable

TSubclassOf< AA...

 

ShowDebugTargetDesiredClass

Class filter for selecting 'ShowDebugTargetActor' when 'bShowDebugForReticleTarget' is true.

Public variable

TArray< FName >

 

ToggledDebugCategories

Array of names specifying what subsets of debug info to display for viewtarget actor.

Constructors

Name Description

Public function

AHUD

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Public function Static

void

 

AddActorToDebugList

(
    AActor* InActor,
    TArray< AActor* >& InOutList,
    UWorld* InWorld
)

Utility function to add an actor to our consideration list for 'showdebug' Only consider visible, non destroyed Actors in the same world the player is in.

Public function Static

void

 

AddComponentOwnerToDebugList

(
    UActorComponent* InComponent,
    TArray< AActor* >& InOutList,
    UWorld* InWorld
)

Utility function to add a component's owner to our consideration list for 'showdebug'

Public function

void

 

AddDebugText

(
    const FString& DebugText,
    AActor* SrcActor,
    float Duration,
    FVector Offset,
    FVector DesiredOffset,
    FColor TextColor,
    bool bSkipOverwriteCheck,
    bool bAbsoluteLocation,
    bool bKeepAttachedToActor,
    UFont* InFont,
    float FontScale,
    bool bDrawShadow
)

Add debug text for a specific actor to be displayed via DrawDebugTextList().

Public function

void

 

AddHitBox

(
    FVector2D Position,
    FVector2D Size,
    FName InName,
    bool bConsumesInput,
    int32 Priority
)

Add a hitbox to the hud

Public function Virtual

void

 

AddPostRenderedActor

(
    AActor* A
)

Add an actor to the PostRenderedActors array

Public function Const

bool

 

AnyCurrentHitBoxHits()

Have any hitboxes been hit this frame.

Public function Const

void

 

Deproject

(
    float ScreenX,
    float ScreenY,
    FVector& WorldPosition,
    FVector& WorldDirection
)

Transforms a 2D screen location into a 3D location and direction

Public function

void

 

Draw2DLine

(
    int32 X1,
    int32 Y1,
    int32 X2,
    int32 Y2,
    FColor LineColor
)

Draws a colored line between two points

Public function

void

 

Draw3DLine

(
    FVector Start,
    FVector End,
    FColor LineColor
)

Draws a colored line between two points

Public function Virtual

void

 

DrawActorOverlays

(
    FVector Viewpoint,
    FRotator ViewRotation
)

Draw overlays for actors that were rendered this tick and have added themselves to the PostRenderedActors array

Public function

void

 

DrawDebugTextList()

Iterate through list of debug text and draw it over the associated actors in world space.

Public function Virtual

void

 

DrawHUD()

The Main Draw loop for the hud. Gets called before any messaging. Should be subclassed

Public function

void

 

DrawLine

(
    float StartScreenX,
    float StartScreenY,
    float EndScreenX,
    float EndScreenY,
    FLinearColor LineColor,
    float LineThickness
)

Draws a 2D line on the HUD.

Public function

void

 

DrawMaterial

(
    UMaterialInterface* Material,
    float ScreenX,
    float ScreenY,
    float ScreenW,
    float ScreenH,
    float MaterialU,
    float MaterialV,
    float MaterialUWidth,
    float MaterialVHeight,
    float Scale,
    bool bScalePosition,
    float Rotation,
    FVector2D RotPivot
)

Draws a material-textured quad on the HUD.

Public function

void

 

DrawMaterialSimple

(
    UMaterialInterface* Material,
    float ScreenX,
    float ScreenY,
    float ScreenW,
    float ScreenH,
    float Scale,
    bool bScalePosition
)

Draws a material-textured quad on the HUD. Assumes UVs such that the entire material is shown.

Public function

void

 

DrawMaterialTriangle

(
    UMaterialInterface* Material,
    FVector2D V0_Pos,
    FVector2D V1_Pos,
    FVector2D V2_Pos,
    FVector2D V0_UV,
    FVector2D V1_UV,
    FVector2D V2_UV,
    FLinearColor V0_Color,
    FLinearColor V1_Color,
    FLinearColor V2_Color
)

Public function

void

 

DrawRect

(
    FLinearColor RectColor,
    float ScreenX,
    float ScreenY,
    float ScreenW,
    float ScreenH
)

Draws a colored untextured quad on the HUD.

Public function Virtual

void

 

DrawSafeZoneOverlay()

Draw the safe zone debugging overlay when enabled

Public function

void

 

DrawText

(
    const FString& Text,
    FLinearColor TextColor,
    float ScreenX,
    float ScreenY,
    UFont* Font,
    float Scale,
    bool bScalePosition
)

Draws a string on the HUD.

Public function

void

 

DrawTexture

(
    UTexture* Texture,
    float ScreenX,
    float ScreenY,
    float ScreenW,
    float ScreenH,
    float TextureU,
    float TextureV,
    float TextureUWidth,
    float TextureVHeight,
    FLinearColor TintColor,
    EBlendMode BlendMode,
    float Scale,
    bool bScalePosition,
    float Rotation,
    FVector2D RotPivot
)

Draws a textured quad on the HUD.

Public function

void

 

DrawTextureSimple

(
    UTexture* Texture,
    float ScreenX,
    float ScreenY,
    float Scale,
    bool bScalePosition
)

Draws a textured quad on the HUD. Assumes 1:1 texel density.

Public function

bool

 

GetActorsInSelectionRectangle

(
    const FVector2D& FirstPoint,
    const FVector2D& SecondPoint,
    TArray< ClassFilter* >& OutAc...,
    bool bIncludeNonCollidingComponents,
    bool bActorMustBeFullyEnclosed
)

Returns the array of actors inside a selection rectangle, with a class filter.

Public function

void

 

GetActorsInSelectionRectangle

(
    TSubclassOf< AActor > ClassFilter,
    const FVector2D& FirstPoint,
    const FVector2D& SecondPoint,
    TArray< AActor* >& OutActors,
    bool bIncludeNonCollidingComponents,
    bool bActorMustBeFullyEnclosed
)

Returns the array of actors inside a selection rectangle, with a class filter.

Public function Virtual

AActor *

 

GetCurrentDebugTargetActor()

Get Target to view 'showdebug' on

Public function Virtual

void

 

GetDebugActorList

(
    TArray< AActor* >& InOutList
)

Get list of considered targets for 'showdebug' This list is built contextually based on which 'showdebug' flags have been enabled.

Public function Virtual Const

UFont *

 

GetFontFromSizeIndex

(
    int32 FontSize
)

Messaging.

Public function Const

const FHUDHi...

 

GetHitBoxAtCoordinates

(
    FVector2D InHitLocation,
    bool bConsumingInput
)

Find the first hitbox containing the given coordinates.

Public function Const

void

 

GetHitBoxesAtCoordinates

(
    FVector2D InHitLocation,
    TArray< const FHUDHitBox* >& ...
)

Finds all the hitboxes containing the given coordinates.

Public function Const

const FHUDHi...

 

GetHitBoxWithName

(
    const FName InName
)

Return the hitbox with the given name

Public function Const

APawn *

 

GetOwningPawn()

Returns the Pawn for this HUD's player.

Public function Const

APlayerContr...

 

GetOwningPlayerController()

Returns the PlayerController for this HUD's player.

Public function Const

void

 

GetTextSize

(
    const FString& Text,
    float& OutWidth,
    float& OutHeight,
    UFont* Font,
    float Scale
)

Returns the width and height of a string.

Public function Virtual

void

 

HandleBugScreenShot()

Gives the HUD a chance to display project-specific data when taking a "bug" screen shot.

Protected function Const

bool

 

IsCanvasValid_WarnIfNot()

Public function Virtual

void

 

NextDebugTarget()

Cycle to next target in our considered targets list for 'showdebug'

Public function Virtual

void

 

NotifyBindPostProcessEffects()

Called in PostInitializeComponents or postprocessing chain has changed (happens because of the worldproperties can define it's own chain and this one is set late).

Public function Virtual

void

 

NotifyHitBoxBeginCursorOver

(
    FName BoxName
)

Native handler, called when a hit box is moused over.

Public function Virtual

void

 

NotifyHitBoxClick

(
    FName BoxName
)

Native handler, called when a hit box is clicked on. Provides the name associated with that box.

Public function Virtual

void

 

NotifyHitBoxEndCursorOver

(
    FName BoxName
)

Native handler, called when a hit box no longer has the mouse over it.

Public function Virtual

void

 

NotifyHitBoxRelease

(
    FName BoxName
)

Native handler, called when a hit box is unclicked. Provides the name associated with that box.

Public function Virtual

void

 

OnLostFocusPause

(
    bool bEnable
)

Pauses or unpauses the game due to main window's focus being lost.

Public function Virtual

void

 

PostRender()

PostRender is the main draw loop.

Public function Virtual

void

 

PreviousDebugTarget()

Cycle to previous target in our considered targets list for 'showdebug'

Public function Const

FVector

 

Project

(
    FVector Location
)

Transforms a 3D world-space vector into 2D screen coordinates

Public function

void

 

ReceiveDrawHUD

(
    int32 SizeX,
    int32 SizeY
)

Hook to allow blueprints to do custom HUD drawing.

Public function

void

 

ReceiveHitBoxBeginCursorOver

(
    const FName BoxName
)

Called when a hit box is moused over.

Public function

void

 

ReceiveHitBoxClick

(
    const FName BoxName
)

Called when a hit box is clicked on. Provides the name associated with that box.

Public function

void

 

ReceiveHitBoxEndCursorOver

(
    const FName BoxName
)

Called when a hit box no longer has the mouse over it.

Public function

void

 

ReceiveHitBoxRelease

(
    const FName BoxName
)

Called when a hit box is unclicked. Provides the name associated with that box.

Public function

void

 

RemoveAllDebugStrings()

Remove all debug strings added via AddDebugText

Public function

void

 

RemoveDebugText

(
    AActor* SrcActor,
    bool bLeaveDurationText
)

Remove debug strings for the given actor

Public function Virtual

void

 

RemovePostRenderedActor

(
    AActor* A
)

Remove an actor from the PostRenderedActors array

Public function

void

 

RenderHitBoxes

(
    FCanvas* InCanvas
)

Debug renderer for this frames hitboxes.

Public function

void

 

SetCanvas

(
    UCanvas* InCanvas,
    UCanvas* InDebugCanvas
)

Set the canvas and debug canvas to use during drawing

Public function Virtual Const

bool

 

ShouldDisplayDebug

(
    const FName& DebugType
)

Check if we should be display debug information for particular types of debug messages.

Public function Virtual

void

 

ShowDebug

(
    FName DebugType
)

Toggles displaying properties of player's current ViewTarget DebugType input values supported by base engine include "AI", "physics", "net", "camera", and "collision"

Public function

void

 

ShowDebugForReticleTargetToggle

(
    TSubclassOf< AActor > DesiredClass
)

Toggles 'ShowDebug' from showing debug info between reticle target actor (of subclass ) and camera view target

Public function Virtual

void

 

ShowDebugInfo

(
    float& YL,
    float& YPos
)

Entry point for basic debug rendering on the HUD.

Public function

void

 

ShowDebugToggleSubCategory

(
    FName Category
)

Toggles sub categories of show debug to customize display

Public function Virtual

void

 

ShowHUD()

Hides or shows HUD

Public function

bool

 

UpdateAndDispatchHitBoxClickEvents

(
    const FVector2D ClickLocation,
    const EInputEvent InEventType
)

Update the list of hitboxes and dispatch events for any hits.

Public function

void

 

UpdateHitBoxCandidates

(
    TArray< FVector2D > InContactPoints
)

Update a the list of hitboxes that have been hit this frame.

Overridden from AActor

Name Description

Public function Virtual

void

 

PostInitializeComponents()

Allow actors to initialize themselves on the C++ side after all of their components have been initialized, only called during gameplay

Constants

Name

Description

GreenColor

OnHUDPostRender

Called from ::PostRender. For less player/actor centered debugging.

OnShowDebugInfo

Callback allowing external systems to register to show debug info.

RedColor

WhiteColor

Pre-defined FColors for convenience.

See Also

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss