x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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"

 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!

Product Version: UE 4.7
Tags:
more ▼

asked May 22 '15 at 07:47 PM in C++ Programming

avatar image

MBrad
10 2 4 5

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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!
 }
more ▼

answered May 22 '15 at 10:06 PM

avatar image

Mark James G
514 44 24 51

avatar image MBrad May 26 '15 at 08:00 PM

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!

avatar image Mark James G May 26 '15 at 09:21 PM

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.

https://forums.unrealengine.com/showthread.php?299-Wiki-Code-Tutorials

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

https://docs.unrealengine.com/latest/INT/Gameplay/ClassCreation/CodeOnly/index.html

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

https://docs.unrealengine.com/latest/INT/API/

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

avatar image MBrad May 26 '15 at 11:12 PM

Awesome, thanks so much!

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question