Download

Trying to add "HUDClass = AMyHUD::StaticClass()" - but cannot find the correct place to do it

It seems like some stuff has changed and some of the old tutorials on line show different code.

For example when I create “New C++ code” and select “gamemode” all I get is this created in my visual studio…

MyGameMode.cpp


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

#include "bloodlust2.h"
#include "MyGameMode.h"

MyGameMode.h


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

#pragma once

#include "GameFramework/GameMode.h"

#include "MyGameMode.generated.h"


/**
 * 
 */
UCLASS()
class BLOODLUST2_API AMyGameMode : public AGameMode
{
	GENERATED_BODY()


		
	
};

so not quite sure where I am supposed to put the


HUDClass = AMyHUD::StaticClass() 

Any suggestions?

You would want to add a FObjectInitializer constructor to your GameMode, like the following:

MyGameMode.h



#pragma once
#include "GameFramework/GameMode.h"
#include "MyGameMode.generated.h"

/**
 * 
 */
UCLASS()
class BLOODLUST2_API AMyGameMode : public AGameMode
{
    GENERATED_BODY()

public:

    /** Base ctor (4.6 style) */
    AMyGameMode (const FObjectInitializer& ObjectInitializer);
};

MyGameMode.cpp


#include "bloodlust2.h"
#include "MyGameMode.h"

AMyGameMode::AMyGameMode(const class FObjectInitializer& ObjectInitializer)
        : Super(ObjectInitializer)
{
    HUDClass = AMyHUD::StaticClass()
}

Thanks… I forgot to do this in my header


public: 

    /** Base ctor (4.6 style) */ 
    AMyGameMode (const FObjectInitializer& ObjectInitializer);