Skip to content
Connecting DocsDocumentation
Main website
Pixel Era/Quick Setup

Use Overlapper in C++

Quick rundown of overlap queries in C++ which mirror blueprints very closely

1. Prepare the level

Follow Add overlap events through source and manager setup, naming your source Poison. Copy the complete header and source below into your game module, then build. The actor creates its Pixel Era Overlapper component.
C++ Overlapper construction and BeginPlay event binding
  1. Create the component
    Overlapper performs the query.
  2. Bind the events
    Your actor supplies the response.
Copy the C++
#include "PE_Overlapper.h"

AOverlapReceiver::AOverlapReceiver()
{
    Overlapper = CreateDefaultSubobject<UPE_Overlapper>(TEXT("Overlapper"));
    SetRootComponent(Overlapper);
    Overlapper->Radius = 34.f;
    Overlapper->Height = 180.f;
}

void AOverlapReceiver::BeginPlay()
{
    Super::BeginPlay();
    Overlapper->OnBeginOverlap.AddDynamic(this, &AOverlapReceiver::BeginOverlap);
    Overlapper->OnEndOverlap.AddDynamic(this, &AOverlapReceiver::EndOverlap);
}

2. Handle Begin and End

Place an OverlapReceiver in the level and move it through the source mesh. bPoisoned becomes true on entry and false on exit. Both handlers receive source-name arrays and use UFUNCTION() for their dynamic bindings.
C++ source-name handlers for Poison entry and exit
  1. Begin response
    Poison enters the capsule.
  2. End response
    Poison leaves the capsule.
Copy the C++
// Both handlers are declared with UFUNCTION() in the header.
void AOverlapReceiver::BeginOverlap(const TArray<FName>& SourceNames)
{
    if (SourceNames.Contains(FName(TEXT("Poison"))))
        bPoisoned = true;
}

void AOverlapReceiver::EndOverlap(const TArray<FName>& SourceNames)
{
    if (SourceNames.Contains(FName(TEXT("Poison"))))
        bPoisoned = false;
}

Add "PixelEraOverlap" to PublicDependencyModuleNames in your module’s .Build.cs.

Complete header

OverlapReceiver.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "OverlapReceiver.generated.h"

class UPE_Overlapper;

UCLASS()
class AOverlapReceiver : public AActor
{
    GENERATED_BODY()

public:
    AOverlapReceiver();

protected:
    virtual void BeginPlay() override;

    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pixel Era")
    TObjectPtr<UPE_Overlapper> Overlapper;

    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Gameplay")
    bool bPoisoned = false;

    UFUNCTION()
    void BeginOverlap(const TArray<FName>& SourceNames);

    UFUNCTION()
    void EndOverlap(const TArray<FName>& SourceNames);
};
Complete source

OverlapReceiver.cpp

#include "OverlapReceiver.h"
#include "PE_Overlapper.h"

AOverlapReceiver::AOverlapReceiver()
{
    Overlapper = CreateDefaultSubobject<UPE_Overlapper>(TEXT("Overlapper"));
    SetRootComponent(Overlapper);
    Overlapper->Radius = 34.f;
    Overlapper->Height = 180.f;
}

void AOverlapReceiver::BeginPlay()
{
    Super::BeginPlay();
    Overlapper->OnBeginOverlap.AddDynamic(this, &AOverlapReceiver::BeginOverlap);
    Overlapper->OnEndOverlap.AddDynamic(this, &AOverlapReceiver::EndOverlap);
}

void AOverlapReceiver::BeginOverlap(const TArray<FName>& SourceNames)
{
    if (SourceNames.Contains(FName(TEXT("Poison"))))
        bPoisoned = true;
}

void AOverlapReceiver::EndOverlap(const TArray<FName>& SourceNames)
{
    if (SourceNames.Contains(FName(TEXT("Poison"))))
        bPoisoned = false;
}
Updated Oct 17, 2026

Search Pixel Era

Type at least two characters to search.