How do i add a pawn sensing component properly in c++?
I tryed this but i get an error:
Error LNK2019 unresolved external symbol “__declspec(dllimport) class UClass * __cdecl Z_Construct_UClass_UPawnSensingComponent_NoRegister(void)” (_imp?Z_Construct_UClass_UPawnSensingComponent_NoRegister@@YAPEAVUClass@@anonymous_user_9674a66c) referenced in function “void __cdecl `dynamic initializer for ‘public: static struct UE4CodeGen_Private::FObjectPropertyParams const Z_Construct_UClass_APirate_Statics::NewProp_PawnSensing’’(void)” (??__E?NewProp_PawnSensing@Z_Construct_UClass_APirate_Statics@@2UFObjectPropertyParams@UE4CodeGen_Private@@anonymous_user_31e84eb0@@YAXXZ) Pirates D:\Unreal Engine 4\Unreal Projects\Pirates\Intermediate\ProjectFiles\Pirate.gen.cpp.obj
.h
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "Pirate.generated.h"
class UPawnSensingComponent;
UCLASS()
class PIRATES_API APirate : public ACharacter
{
GENERATED_BODY()
public:
APirate();
protected:
UPROPERTY(VisibleDefaultsOnly, Category = "Components")
UPawnSensingComponent* PawnSensing;
UFUNCTION()
void SeePawn(APawn* Pawn);
virtual void BeginPlay() override;
};
.cpp
#include "Pirate.h"
#include "Perception/PawnSensingComponent.h"
APirate::APirate()
{
PawnSensing = CreateDefaultSubobject<UPawnSensingComponent>(TEXT("PawnSensing"));
}
void APirate::SeePawn(APawn* Pawn)
{
//nothing... yet
}
void APirate::BeginPlay()
{
Super::BeginPlay();
PawnSensing->OnSeePawn.AddDynamic(this, &APirate::SeePawn);
}