Adding collision sphere C++ error, new to Unreal

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"

class LEARNING_BLANK_API ANPCExample : public ACharacter

    // Sets default values for this character's properties

    // 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
    // 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()


// Called every frame
void ANPCExample::Tick( float DeltaTime )
    Super::Tick( DeltaTime );


// Called to bind functionality to input
void ANPCExample::SetupPlayerInputComponent(class UInputComponent* 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->OnComponentBeginOverlap.AddDynamic(this, &ANPC::Prox);
    NPCMessage = "test message";

Thanks in advance for your help!

In your .H file you need to add this to your NPCExample constructor.

NPCExample(const FObjectInitializer& ObjectInitializer);

Then in your .CPP file you’ll need the following.

ANPCExample::ANPCExample(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
  //Your lovely code will go here!

Okay, I see. It seems that there is a bunch of outdated stuff in the tutorials I’m using. Any chance you know a good recent one?
Thanks for your help!

Epic is usually changing their engine via updates all the time. As a result some tutorials might get lost in translation and be slightly outdated but for the most part still usable. Just a slight syntax change.

I haven’t checked out the tutorials in a long, long time but I believe there is a thread dedicated to the wiki tutorials on the forums. You might want to check those out.

I’m pretty sure Rama is always updating it or making new ones. Also, regarding your current question…

Go ahead and give that one a try and for reference go ahead and use the following link:

Trust me when I say that the API is going to be your new best friend. :), good luck.

Awesome, thanks so much!