Download

LNK2001,2019 compilation errors

Good day, I’m learning from the book by Steve Santello Developing RPG games in Unreal, I encountered a problem when compiling GameInstance. As I understand from reading in various articles, I have uncertainty in the function TArray<UGameCharacter*> PartyMembers; and GENERATED_BODY () URPGGameInstance(const class FObjectInitializer& ObjectInitializer);
The third day I’m trying to figure it out, but it seems that at the moment I don’t have enough knowledge to figure it out on my own

Ошибка LNK2019 ��뫪� �� ��ࠧ�襭�� ���譨� ᨬ��� “private: __cdecl URPGGameInstance::URPGGameInstance(class FObjectInitializer const &)” (??0URPGGameInstance@@AEAA@AEBVFObjectInitializer@@@Z) � �㭪樨 “public: static void __cdecl URPGGameInstance::__DefaultConstructor(class FObjectInitializer const &)” (?__DefaultConstructor@URPGGameInstance@@SAXAEBVFObjectInitializer@@@Z). RPG C:\Users\asdhu\Documents\Unreal Projects\RPG\Intermediate\ProjectFiles\RPGGameInstance.cpp.obj 1
Ошибка LNK2001 ��ࠧ�襭�� ���譨� ᨬ��� “private: __cdecl URPGGameInstance::URPGGameInstance(class FObjectInitializer const &)” (??0URPGGameInstance@@AEAA@AEBVFObjectInitializer@@@Z). RPG C:\Users\asdhu\Documents\Unreal Projects\RPG\Intermediate\ProjectFiles\RPGGameInstance.gen.cpp.obj 1
Ошибка LNK1120 ��ࠧ�襭��� ���譨� �����⮢: 1 RPG C:\Users\asdhu\Documents\Unreal Projects\RPG\Binaries\Win64\UE4Editor-RPG.dll 1


#pragma once
#include “GameCharacter.h”

#include “Engine/DataTable.h”
#include “CoreMinimal.h”
#include “Engine/GameInstance.h”
#include “RPGGameInstance.generated.h”

UCLASS()
class RPG_API URPGGameInstance : public UGameInstance
{
GENERATED_BODY()
URPGGameInstance(const class FObjectInitializer& ObjectInitializer);
public:
void Init();
public:
TArray<UGameCharacter*> PartyMembers;

protected:
bool isInitialized;

};


#include “RPGGameInstance.h”

void URPGGameInstance::Init()
{
if(this->isInitialized) return;
this->isInitialized = true;
// locate characters asset
UDataTable* characters = Cast<UDataTable>(StaticLoadObject(UDataTable::StaticClass(), NULL, TEXT(“DataTable’/Game/CharacterClassInfo.CharacterClassInfo’”)));
if(characters == NULL)
{
UE_LOG(LogTemp, Error, TEXT(“Characters data table not found!”));
return;
}
// locate character
FCharacterInfo* row = characters->FindRow<FCharacterInfo>(TEXT(“S1”), TEXT(“LookupCharacterClass”));
if(row == NULL)
{
UE_LOG(LogTemp, Error, TEXT(“Character ID ‘S1’ not found!”));
return;
}
// add character to party
this->PartyMembers.Add(UGameCharacter::CreateGameCharacter(row, this));


#pragma once
#include “Engine/DataTable.h”
#include “FCharacterInfo.h”
#include “FCharacterClassInfo.h”
#include “GameCharacter.generated.h”
UCLASS(BlueprintType)
class RPG_API UGameCharacter : public UObject
{
GENERATED_BODY()
public:
FCharacterClassInfo* ClassInfo;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = CharacterInfo)
FString CharacterName;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = CharacterInfo)
int32 MHP;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = CharacterInfo)
int32 MMP;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = CharacterInfo)
int32 HP;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = CharacterInfo)
int32 MP;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = CharacterInfo)
int32 ATK;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = CharacterInfo)
int32 DEF;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = CharacterInfo)
int32 LUCK;
public:
static UGameCharacter* CreateGameCharacter(FCharacterInfo* characterInfo,UObject* outer);
public:
void BeginDestroy() override;


#include “GameCharacter.h”

UGameCharacter* UGameCharacter::CreateGameCharacter(FCharacterInfo* characterInfo, UObject* outer)
{
UGameCharacter* character = NewObject<UGameCharacter>(outer);
// locate character classes asset
UDataTable* characterClasses = Cast<UDataTable>(StaticLoadObject(UDataTable::StaticClass(), NULL, TEXT(“DataTable’/Game/CharacterInfo.CharacterInfo’”)));
if(characterClasses == NULL)
{
UE_LOG(LogTemp, Error, TEXT(“Character classes datatable not found!”));
}
else
{
character->CharacterName = characterInfo->Character_Name;
FCharacterClassInfo* row = characterClasses->FindRow<FCharacterClassInfo>(* (characterInfo->Class_ID), TEXT(“LookupCharacterClass”));
character->ClassInfo = row;
character->MHP = character->ClassInfo->StartMHP;
character->MMP = character->ClassInfo->StartMMP;
character->HP = character->MHP;
character->MP = character->MMP;
character->ATK = character->ClassInfo->StartATK;
character->DEF = character->ClassInfo->StartDEF;
character->LUCK = character->ClassInfo->StartLuck;
}
return character;
}

void UGameCharacter::BeginDestroy()
{
Super::BeginDestroy();
}

I found a solution, maybe someone will encounter this in the file RPGGameInstance. h it was necessary to add the line:
UCLASS()
class RPG_API URPGGameInstance : public UGameInstance
{
GENERATED_BODY()
URPGGameInstance(const class FObjectInitializer& ObjectInitializer)
**: Super(ObjectInitializer)
{

};**

You can close the topic.