AHUD

Inheritance Hierarchy

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

Protected variable

UCanvas *

 

Canvas

Canvas to Draw HUD on.

Protected variable

UCanvas *

 

DebugCanvas

'Foreground' debug canvas, will draw in front of Slate UI.

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

TArray < AActor ...

 

PostRenderedActors

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

Public variable

float

 

RenderDelta

Time since last HUD render.

Public variable

TArray < FName >

 

ToggledDebugCategories

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

Functions

Name Description

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

bool

 

AnyCurrentHitBoxHits()

Have any hitboxes been hit this frame.

Public function

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

UFont *

 

GetFontFromSizeIndex

(
    int32 FontSize
)

============================================================================= Messaging.

Public function

const FHUDHi ...

 

GetHitBoxAtCoordinates

(
    FVector2D InHitLocation,
    bool bConsumingInput
)

Find the first hitbox containing the given coordinates.

Public function

void

 

GetHitBoxesAtCoordinates

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

Finds all the hitboxes containing the given coordinates.

Public function

const FHUDHi ...

 

GetHitBoxWithName

(
    const FName InName
)

Return the hitbox with the given name

Protected function

APawn *

 

GetOwningPawn()

Returns the Pawn for this HUD's player.

Protected function

APlayerContr ...

 

GetOwningPlayerController()

Returns the PlayerController for this HUD's player.

Public function

void

 

GetTextSize

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

============================================================================= Kismet API for simple HUD drawing.

Public function Virtual

void

 

HandleBugScreenShot()

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

Protected function

bool

 

IsCanvasValid_WarnIfNot()

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

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

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()

============================================================================= Utils 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.

Constants

Name

Description

GreenColor

OnShowDebugInfo

Callback allowing external systems to register to show debug info.

RedColor

WhiteColor

Pre-defined FColors for convenience.

See Also

UCanvas

FHUDHitBox

FDebugTextInfo

References

Module

Engine

Header

Runtime/Engine/Classes/GameFramework/HUD.h