# Errors while trying to draw HUD

**URL:** <https://forums.unrealengine.com/t/errors-while-trying-to-draw-hud/410015>\
**Category:** UI\
**Tags:** hud, hud-class, unreal-engine, UE4, CPP, question\
**Created:** [November 19, 2017, 12:19pm UTC](https://forums.unrealengine.com/t/errors-while-trying-to-draw-hud/410015 "2017-11-19T12:19:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![M0latov](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@M0latov](https://forums.unrealengine.com/u/M0latov)\
**Post date:** [November 19, 2017, 12:19pm UTC](https://forums.unrealengine.com/t/errors-while-trying-to-draw-hud/410015/1 "2017-11-19T12:19:32Z")

</div>

I’m currently on part 3.5 of the beginner fps tutorial, and am trying to write the code nessacary in order to draw the hud.  
Only problem is, once i write in the code, i get about 24 errors, consisting of messages like:

```
>`'TileItem': undeclared identifier	
>'FCanvasTileItem': undeclared identifier	
>'CrossHairDrawPosition': undeclared identifier	
>identifier "SE_BLEND_Translucent" is undefined

```

this is my HUD header file:

```
#include "GameFramework/HUD.h"
#include "BasicFpsHUD.generated.h"

/**
 * 
 */
UCLASS()
class BASICFPS_API ABasicFpsHUD : public AHUD
{
	GENERATED_BODY()
	

protected:
	//creates a pointer to a crosshair texture that will be drawn at the center of the screen.
	UPROPERTY(EditAnywhere)
	UTexture2D * CrosshairTexture;

public:
	//calls for the HUD to be drawn.
	virtual void DrawHUD() override;

	
	
};

```

This is my HUD cpp file:

```
// Fill out your copyright notice in the Description page of Project Settings.

#include "BasicFpsHUD.h"

void ABasicFpsHUD::DrawHUD()
{
	Super::DrawHUD();

	if (CrosshairTexture)
	{
		//find the center of the canvas on the HUD.
		FVector2D Center(Canvas->ClipX * 0.5f, Canvas->ClipY * 0.5f);

		//offset by half the dimensions so that the centre of the texture aligns with the center of the canvas.
		FVector2D CrossHairDrawPosition(Center.X - (CrosshairTexture->GetSurfaceWidth() * 0.5f);

		//draw crosshair at the centrepoint.
		FCanvasTileItem TitleItem(CrossHairDrawPosition, CrosshairTexture->Resource, FLinearColor::White);
		TileItem.BlendMode = SE_BLEND_Translucent;
		Canvas->DrawItem(TileItem);
	}
}

```

I’m thinking a missing header file, but the problem is: which one?

part of the tutorial i’m on:

[https://docs.unrealengine.com/latest/INT/Programming/Tutorials/FirstPersonShooter/3/5/index.html](https://docs.unrealengine.com/latest/INT/Programming/Tutorials/FirstPersonShooter/3/5/index.html)

**EDIT:**

I’ve fixed the problem, there were mostly a few typos, in conjunction to too few argument types passed into CrossHairDrawPosition

the orginal code was:

```
FVector2D CrossHairDrawPosition(Center.X - (CrosshairTexture->GetSurfaceWidth() * 0.5f)))

```

instead of:

```
FVector2D CrossHairDrawPosition(Center.X - (CrosshairTexture->GetSurfaceWidth() * 0.5f), Center.Y - (CrosshairTexture->GetSurfaceHeight) * 0.5f);
```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_71046e02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_71046e02](https://forums.unrealengine.com/u/anonymous_user_71046e02)\
**Post date:** [November 23, 2017, 8:37am UTC](https://forums.unrealengine.com/t/errors-while-trying-to-draw-hud/410015/2 "2017-11-23T08:37:02Z")

</div>

I have the same problem.Have you solved this problem?

---

<div class="post-metadata">

**Author:** ![M0latov](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@M0latov](https://forums.unrealengine.com/u/M0latov)\
**Post date:** [November 23, 2017, 5:55pm UTC](https://forums.unrealengine.com/t/errors-while-trying-to-draw-hud/410015/3 "2017-11-23T17:55:06Z")

</div>

Unfortunately not, but i’ll keep you posted if i do get a solution

---

<div class="post-metadata">

**Author:** ![c4tnt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@c4tnt](https://forums.unrealengine.com/u/c4tnt)\
**Post date:** [November 23, 2017, 9:24pm UTC](https://forums.unrealengine.com/t/errors-while-trying-to-draw-hud/410015/4 "2017-11-23T21:24:44Z")

</div>

At least I see one misprint:  
On line 20 there is FCanvasTileItem TitleItem but next it is named TileItem

Next error may be caused bu obsolete syntax - try to use ESimpleElementBlendMode::SE\_BLEND\_Translucent instead of SE\_BLEND\_Translucent

---

<div class="post-metadata">

**Author:** ![M0latov](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@M0latov](https://forums.unrealengine.com/u/M0latov)\
**Post date:** [November 24, 2017, 5:07pm UTC](https://forums.unrealengine.com/t/errors-while-trying-to-draw-hud/410015/5 "2017-11-24T17:07:02Z")

</div>

See edit in the post: I’ve fixed the problem

---

<div class="post-metadata">

**Author:** ![Anonymous\_1bf18549e8485aa771d4eaf0d5ce2e98](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_1bf18549e8485aa771d4eaf0d5ce2e98](https://forums.unrealengine.com/u/Anonymous_1bf18549e8485aa771d4eaf0d5ce2e98)\
**Post date:** [December 11, 2017, 3:48pm UTC](https://forums.unrealengine.com/t/errors-while-trying-to-draw-hud/410015/6 "2017-12-11T15:48:17Z")

</div>

But I was told that I used the undefined type “UCanvas”,whats wrong?

---

<div class="post-metadata">

**Author:** ![Anonymous\_1bf18549e8485aa771d4eaf0d5ce2e98](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_1bf18549e8485aa771d4eaf0d5ce2e98](https://forums.unrealengine.com/u/Anonymous_1bf18549e8485aa771d4eaf0d5ce2e98)\
**Post date:** [December 11, 2017, 3:49pm UTC](https://forums.unrealengine.com/t/errors-while-trying-to-draw-hud/410015/7 "2017-12-11T15:49:05Z")

</div>

But I was told that I used the undefined type “UCanvas”,whats wrong?

---

<div class="post-metadata">

**Author:** ![Anonymous\_1bf18549e8485aa771d4eaf0d5ce2e98](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_1bf18549e8485aa771d4eaf0d5ce2e98](https://forums.unrealengine.com/u/Anonymous_1bf18549e8485aa771d4eaf0d5ce2e98)\
**Post date:** [December 12, 2017, 1:52pm UTC](https://forums.unrealengine.com/t/errors-while-trying-to-draw-hud/410015/8 "2017-12-12T13:52:53Z")

</div>

But I was told that I used the undefined type “UCanvas”,whats wrong?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bb60661a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bb60661a](https://forums.unrealengine.com/u/anonymous_user_bb60661a)\
**Post date:** [December 20, 2018, 2:07pm UTC](https://forums.unrealengine.com/t/errors-while-trying-to-draw-hud/410015/9 "2018-12-20T14:07:11Z")

</div>

I know this is old, but I found the solution. UE4 changed the way it includes files. It used to be all in one, but now you must include files individually. Search the UE4 C++ API for each item for the header file.

for these, they are:

```
#include "Runtime/Engine/Classes/Engine/Texture2D.h"
#include "Runtime/Engine/Public/CanvasItem.h"
#include "Runtime/Engine/Classes/Engine/Canvas.h"

```

---

<div class="post-metadata">

**Author:** ![xGETxdestroyed](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xGETxdestroyed](https://forums.unrealengine.com/u/xGETxdestroyed)\
**Post date:** [August 3, 2019, 9:01pm UTC](https://forums.unrealengine.com/t/errors-while-trying-to-draw-hud/410015/10 "2019-08-03T21:01:42Z")

</div>

Thanks for providing these headers, I was stuck on this for so long!
