Hi all,
I’m following a tutorial to get myself familiar with Unreal and C++ and am running in to a compiler error that I can’t figure out. I’m currently trying to add a collider to my geo in code. The error I’m getting is
‘ANPCExample::ANPCExample(const FPostContructInitializeProperties &)’ : overloaded member function not found in ‘ANPCExample’ (line 40 col1)
My header file:
#pragma once
#include "GameFramework/Character.h"
#include "NPCExample.generated.h"
UCLASS()
class LEARNING_BLANK_API ANPCExample : public ACharacter
{
GENERATED_BODY()
public:
// Sets default values for this character's properties
ANPCExample();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
//add collider for NPC
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Collision)
USphereComponent* proxSphere;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = NPCMessage)
FString NPCMessage;
};
and the C++ file:
#include "learning_blank.h"
#include "NPCExample.h"
#include "ExampleHUD.h"
// Sets default values
ANPCExample::ANPCExample()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void ANPCExample::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ANPCExample::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
// Called to bind functionality to input
void ANPCExample::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
Super::SetupPlayerInputComponent(InputComponent);
}
//add a collision sphere to the character
ANPCExample::ANPCExample(const class FPostContructInitializeProperties& PCIP) : Super(PCIP)
{
ProxSphere = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("Proximity Sphere"));
ProxSphere->AttachTo(RootComponent);
ProxSphere->SetSphereRadius(32.f);
ProxSphere->OnComponentBeginOverlap.AddDynamic(this, &ANPC::Prox);
NPCMessage = "test message";
}
Thanks in advance for your help!