# Overlapping doesn' happen

**URL:** <https://forums.unrealengine.com/t/overlapping-doesn-happen/479411>\
**Category:** World Creation\
**Tags:** overlap, child-class, unreal-engine, Physics, Collision, question\
**Created:** [February 28, 2021, 5:30pm UTC](https://forums.unrealengine.com/t/overlapping-doesn-happen/479411 "2021-02-28T17:30:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![user\_03f0a1364975325bb3762b9b0e48114788315f551ac1f0f104b5b5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@user\_03f0a1364975325bb3762b9b0e48114788315f551ac1f0f104b5b5](https://forums.unrealengine.com/u/user_03f0a1364975325bb3762b9b0e48114788315f551ac1f0f104b5b5)\
**Post date:** [February 28, 2021, 5:30pm UTC](https://forums.unrealengine.com/t/overlapping-doesn-happen/479411/1 "2021-02-28T17:30:01Z")

</div>

What I want is, When player is overlapping with DangerZone, give him some messages.

I made OnActorBeginOverlap function in “Zone” class and “DangerZone” is child class of " Zone" class.

No VS or UE4 errors but also No Overlapping happens.

Is there any problems to c++ codes? or what should I check?

```
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "GameplayTagContainer.h"
#include "Components/BoxComponent.h"
#include "Zone.generated.h"

UCLASS()
class LOC_API AZone : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AZone();

	UPROPERTY()
	UBoxComponent* CollisionMesh;

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Use Only once at beginplay and in Editor
	UFUNCTION(BlueprintInternalUseOnly)
		void SetZoneNameTag();

	UFUNCTION()
	virtual void OnActorBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
	
	// Do not access and change
	UPROPERTY(BlueprintReadOnly)
		FName ZoneName;
	
};

// Fill out your copyright notice in the Description page of Project Settings.

#include "Zone/Zone.h"

// Sets default values
AZone::AZone()
	: ZoneName{}
{
 	// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = false;
	CollisionMesh = CreateDefaultSubobject<UBoxComponent>(FName("Collision Mesh"));
	SetRootComponent(CollisionMesh);	
}

// Called when the game starts or when spawned
void AZone::BeginPlay()
{
	Super::BeginPlay();
	SetZoneNameTag();
}

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

}

void AZone::OnActorBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	
		GEngine->AddOnScreenDebugMessage(-1, 5,FColor::Red,"Success");	
}

// DoN Call Except RightAfter BeginPlay. This Must be call once.
void AZone::SetZoneNameTag()
{
	ZoneName = FName("ZoneName."+this->GetName());
	Tags.Add(ZoneName);
	GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, ZoneName.ToString());
}

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Zone.h"
#include "DangerZone.generated.h"

/**
 * 
 */
UCLASS()
class LOC_API ADanerZone : public AZone
{
	GENERATED_BODY()

};

```

---

<div class="post-metadata">

**Author:** ![GrumbleBunny](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GrumbleBunny](https://forums.unrealengine.com/u/GrumbleBunny)\
**Post date:** [March 15, 2021, 12:17pm UTC](https://forums.unrealengine.com/t/overlapping-doesn-happen/479411/2 "2021-03-15T12:17:10Z")

</div>

I think OnActorBeginOverlap is a blueprint event, not a c++ method you can override. Try adding your overlap function as a delegate to the CollisionMesh like so:

```
CollisionMesh->OnComponentBeginOverlap.AddDynamic( this, &AZone::OnActorBeginOverlap);

```

You might have to change the signature of AZone::OnActorBeginOverlap to match OnComponentBeginOverlap though.
