‘ReceiveActorBeginOverlap’ marked ‘override’ but does not override any member functions – (Unreal Engine 4 with C++, Mac OSX)

Posted on Updated on

スクリーンショット 2015-09-20 21.15.00

After playing with Cocos2dx and Unity 5, I decided to challenge myself even further by working on a test project (FPS, 3rd person shooter etc) using Unreal Engine 4 with C++.

While working on a first person shooter project, I was in the middle of creating power up / health pick up items. All was going well until I ran into this error message:

‘ReceiveActorBeginOverlap’ marked ‘override’ but does not override any member functions

My source code below:

.h header file

    #pragma once
     #include "GameFramework/Actor.h"
     #include "HealthPack.generated.h"

    class TESTFPS_API AHealthPack : public AActor
	    AHealthPack(const FObjectInitializer& ObjectInitializer);	

	    virtual void 	BeginPlay()  override;
	    virtual void 	Tick( float DeltaSeconds ) override;
	    virtual void 	ReceiveActorBeginOverlap(class AActor* Other)	override;	

And in my .cpp implementation file l declare this method like this:

    void AHealthPack::ReceiveActorBeginOverlap(class AActor* Other)	
     	if (Other != NULL)
	    	if (CanBePickedUp(Cast<ATestFPSCharacter>(Other)))

Turns out that “ReceiveActorBeginOverlap” is not virtual so you cannot override this method (anymore). So to solve this you need to override <strong"NotifyActorBeginOverlap" and then call Super inside this function. Modifying the lines above to below resolves my error:

.h header file:

virtual void 	NotifyActorBeginOverlap(class AActor* Other)	override;

.cpp implementation file:

 *	Check if we can pick up a health pack
void AHealthPack::NotifyActorBeginOverlap(class AActor* Other)	

	if (Other != NULL)
		if (CanBePickedUp(Cast< ATestFPSCharacter >(Other)))
			HandlePickUp(Cast< ATestFPSCharacter >(Other));

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s