Errors while trying to draw HUD

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"

class BASICFPS_API ABasicFpsHUD : public AHUD

	//creates a pointer to a crosshair texture that will be drawn at the center of the screen.
	UTexture2D * CrosshairTexture;

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

	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;

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

part of the tutorial i’m on:


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

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

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

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

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

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

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

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

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"

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