FPS Tutorial HUD code not compiling

I’ve been following the the FPS tutorial and am having some trouble with getting it to compile after having completed the section on overriding the HUD function to add your own crosshair.

This here’s the code from the .h file:

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

#pragma once

#include "GameFramework/HUD.h"
#include "FPSHUD.generated.h"

/**
 * 
 */
UCLASS()
class FPSPROJECT_API AFPSHUD : public AHUD
{
	GENERATED_UCLASS_BODY()

	/* Primary draw call for the HUD*/
	virtual void DrawHUD() override;

	private:
		/* Crosshair asset pointer*/
		UTexture2D* CrosshairTex;

		// Set the crosshair texture
		static ConstructorHelpers::FObjectFinder<UTexture2D> CrosshairTexObj(TEXT("Texture2D'/Game/crosshair.crosshair'"));
		CrosshairTex = CrosshairTexObj.Object;
		CrosshairTex = CrosshairTexObj.Object;
};

Whenever I try to compile it UE complains about there being a syntax error in this line:

static ConstructorHelpers::FObjectFinder CrosshairTexObj(TEXT(“Texture2D’/Game/crosshair.crosshair’”));

which I’ve been unable to find any errors with. Any help with this is appreciated.

// Set the crosshair texture
static ConstructorHelpers::FObjectFinder CrosshairTexObj(TEXT(“Texture2D’/Game/crosshair.crosshair’”));
CrosshairTex = CrosshairTexObj.Object;
CrosshairTex = CrosshairTexObj.Object;

That part of the code needs to be in the .cpp file, where the constructor is.

AFPSHUD::AFPSHUD(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
}

Note: 4.6 No longer uses FPostConstructInitializeProperties I believe so you should be able to omit that part if using 4.6.

On 4.6, to make the tutorial HUD work, I had to do the following:

In FPSHUD.h, add the following before the closing };

 AFPSHUD(const FObjectInitializer& ObjectInitializer);

Then in FPSHUD.cpp, I placed the following after the includes but prior to the DrawHUD overide.

AFPSHUD::AFPSHUD(const FObjectInitializer& ObjectInitializer)
       : Super(ObjectInitializer)
   {
	   // Set the crosshair texture
    static ConstructorHelpers::FObjectFinder<UTexture2D> CrosshairTexObj(TEXT("Texture2D'/Game/crosshair.crosshair'"));
    CrosshairTex = CrosshairTexObj.Object;
   }

Whether correct or not, I don’t know, but it works.

The constructor was changed a bit, but as long as you don’t copy paste the code, you should be able to use the Paramters from the newly created class.