Inheritance. Creating a child class derived from ATriggerBox

Hi.

I am attempting to inherit the function “OnActorBeginOverlap” from ATriggerBox

I’ve made a child class from ATriggerBox, but am receiving the error “member function declared with ‘override’ does not override a base class member”

Header file:

233313-inheritance-support.png

Thank you for your assistance.

Hey.

Well, the error says all. There is no such function in any of your base classes.
The OnActorBeginOverlap is a dynamic multicast delegate. And it’s a member of AActor class (see API).

Example usage:

Header

void BeginPlay() override;

UFUNCTION() // required to bind this function to dynamic multicast delegate
void OnActorBeginOverlap_Handler(AActor* OverlappedActor, AActor* OtherActor);   

Cpp

void ACameraBoundsTrigger::BeginPlay()
{
	Super::BeginPlay();

	OnActorBeginOverlap.AddDynamic(this, &ACameraBoundsTrigger::OnActorBeginOverlap_Handler);
}

void ACameraBoundsTrigger::OnActorBeginOverlap_Handler(AActor* OverlappedActor, AActor* OtherActor)
{
	// Do stuff
}

Hope this helps. Cheers.

Thanks for your time. This has pointed me in the right direction and I really appreciate it. I want to be sure I’m also doing something else right, related to UFUNCTION.

If I wanted to use “BeginPlay” would I define it in the header like so?

UFUNCTION()
void BeginPlay();

Thanks again.

You’re welcome. :]

BeginPlay is a function of AActor. So you’ll have to override it. Like so:

void BeginPlay() override;

Also, you don’t have to add UFUNCTION to overriden function as they iherit that from their parents.

Additionally, in most cases there’s no point in adding empty UFUNCTION unless you need to expose given function to UE4 reflection system (that’s why dynamic multicast delegates need that). In your case, the UFUNCTION macro can be skipped.

Cheers.