I try to create an inventory for an Escape Room game following this tutorial: UNREAL INVENTORY STEP BY STEP || Unreal Engine Tutorial - YouTube
In my Item.h i have this code:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Components/StaticMeshComponent.h"
#include "Item.generated.h"
UCLASS()
class VIATADESTUDENT_API AItem : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AItem();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
bool isVisible;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
FORCEINLINE class UStaticMeshComponent* GetMesh() const { return itemMesh; }
UFUNCTION(BlueprintPure, Category = "Item")
bool GetActive();
UFUNCTION(BlueprintCallable, Category = "Item")
void SetActive(bool visible);
UFUNCTION(BlueprintCallable)
void Touched();
UPROPERTY(EditDefaultsOnly)
FString name;
UPROPERTY(EditDefaultsOnly)
FName itemID;
private:
UPROPERTY(VisibleAnywhere, Category = "Item")
class UStaticMeshComponent* itemMesh;
};
And in my Item.cpp i have this:
// Fill out your copyright notice in the Description page of Project Settings.
#include "Item.h"
// Sets default values
AItem::AItem()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
isVisible = true;
itemMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("itemMesh"));
RootComponent = itemMesh;
GetMesh()->SetSimulatePhysics(true);
name = "null";
itemID = FName("null");
}
// Called when the game starts or when spawned
void AItem::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AItem::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
bool AItem::GetActive()
{
return isVisible;
}
void AItem::SetActive(bool visible)
{
isVisible = visible;
}
void AItem::Touched()
{
this->SetActive(false);
this->SetActorHiddenInGame(true);
}
This is the error:
Item.gen.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl AItem::SetActive(bool)" (?SetActive@AItem@@QEAAX_N@Z) referenced in function "public: static void __cdecl AItem::execSetActive(class UObject *,struct FFrame &,void * const)" (?execSetActive@AItem@@SAXPEAVUObject@@AEAUFFrame@@QEAX@Z)
Item.gen.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl AItem::Touched(void)" (?Touched@AItem@@QEAAXXZ) referenced in function "public: static void __cdecl AItem::execTouched(class UObject *,struct FFrame &,void * const)" (?execTouched@AItem@@SAXPEAVUObject@@AEAUFFrame@@QEAX@Z)
D:\Unreal Engine Projects\Viata de Student\ViataDeStudent\Binaries\Win64\UnrealEditor-ViataDeStudent.patch_3.exe : fatal error LNK1120: 2 unresolved externals
Failed to link patch (0.000s) (Exit code: 0x460)
---------- Finished (0.000s) ----------
Please help me