PLEASE HELP. I have an Issue in the FPS SHOOTER TUTORIAL FROM EPIC GAMES PAGE.
In the (FPS HUD headerfile), I can t compile the red underlined “”““Resource””“” issue.
Have anybody a solution for that.
Tanks you very much.
PLEASE HELP. I have an Issue in the FPS SHOOTER TUTORIAL FROM EPIC GAMES PAGE.
In the (FPS HUD headerfile), I can t compile the red underlined “”““Resource””“” issue.
Have anybody a solution for that.
Tanks you very much.
I’m also looking for a solution to this if I find one I’ll post an answer my IDE says “Cannot resolve symbol”. These tutorials are full of typos and things being misspelled or outdated information just copy and pasted over. It would be nice if the documentation was able to be edited and updated by the community instead of having to search forums for answers.
OK I found the Answer for anyone who also runs into this issue:
In a nut shell there were two issues that were caused due to outdated information in the tutorial.
The First issue was with this line:
FVector2D CrossHairDrawPosition(Center.X - (CrosshairTexture->GetSurfaceWidth() * 0.5f), Center.Y - (CrosshairTexture->GetSurfaceHeight() * 0.5f));
the GetSurfaceWidth() and GetSurfaceHeight() are outdated at the time of this reply.
You need to use:
GetSizeX() and GetSizeY()
In the new example it should look like this now:
FVector2D CrosshairDrawPosition(Center.X - (CrosshairTexture->GetSizeX() * 0.5f), Center.Y - (CrosshairTexture->GetSizeY() * 0.5f));
The Second issue is that the CrosshairTexture->Resource is using the wrong overload (FTexture*) and can sometimes be null. A safer option is to use the UTexture* overload with CrosshairTexture-> GetResource()
old line:
FCanvasTileItem TileItem(CrosshairDrawPosition, CrosshairTexture->Resource, FLinearColor::White);
New Line:
FCanvasTileItem TileItem(CrosshairDrawPosition, CrosshairTexture->GetResource(), FLinearColor::White);
This should hopefully fix the issue for you and anyone else (unless something changes again).
You kind of have to be careful with these tutorials they often have mistakes and outdated information I have been going through them one by one for my own learning purposes and have found several major issues along the way.
As a reference the FPSHUD.cpp file should now look like this:
// Fill out your copyright notice in the Description page of Project Settings.
include “FPSHUD.h”
void AFPSHUD::DrawHUD()
{
Super::DrawHUD();
if (CrosshairTexture)
{
//find the center of our canvas
FVector2D Center(Canvas->ClipX * 0.5f, Canvas->ClipY * 0.5f);
//Offset by half of the texture's dimensions so that the center of the texture aligns with the center of the canvas.
FVector2D CrosshairDrawPosition(Center.X - (CrosshairTexture->GetSizeX() * 0.5f), Center.Y - (CrosshairTexture->GetSizeY() * 0.5f));
//Draw the crosshair at the centerpoint
FCanvasTileItem TileItem(CrosshairDrawPosition, CrosshairTexture->GetResource(), FLinearColor::White);
TileItem.BlendMode = SE_BLEND_Translucent;
Canvas->DrawItem(TileItem);
}
}