# Can't trigger callback USphereComponent collision

**URL:** <https://forums.unrealengine.com/t/cant-trigger-callback-uspherecomponent-collision/355039>\
**Category:** World Creation\
**Tags:** unreal-engine, Collision, question, CPP\
**Created:** [April 22, 2016, 1:18pm UTC](https://forums.unrealengine.com/t/cant-trigger-callback-uspherecomponent-collision/355039 "2016-04-22T13:18:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_c9e458b7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_c9e458b7](https://forums.unrealengine.com/u/anonymous_user_c9e458b7)\
**Post date:** [April 22, 2016, 1:18pm UTC](https://forums.unrealengine.com/t/cant-trigger-callback-uspherecomponent-collision/355039/1 "2016-04-22T13:18:55Z")

</div>

New to UE4 and C++. I am trying to get some basic collision/proximity code working. I can see the ProxSphere in blueprint editor and the sphere is visible in the editing viewport. When I run the scene it logs out the “NPC INIT” message from the constructor, but I can’t seem to be able to get the Prox function to run when player character  
enters the sphere.

`NPC.h`

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

#pragma once

#include "GameFramework/Character.h"
#include "NPC.generated.h"

UCLASS()
class GOLDENEGG_API ANPC : public ACharacter
{
    GENERATED_BODY()

■■■■■:
    // The sphere that the player can collide with to get item
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Collision)
    USphereComponent* ProxSphere;

   ANPC();

    UFUNCTION()
    void Prox(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);

};

```

`NPC.cpp`

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

#include "GoldenEgg.h"
#include "NPC.h"
#include "Avatar.h"
#include "MyHUD.h"

// Sets default values
ANPC::ANPC()
{
    UE_LOG(LogTemp, Warning, TEXT("NPC INIT"));
    ProxSphere = CreateDefaultSubobject<USphereComponent>(TEXT("Proximity Sphere"));
    ProxSphere->InitSphereRadius(120.0f);
    ProxSphere->AttachParent = RootComponent;
    ProxSphere->OnComponentBeginOverlap.AddDynamic(this, &ANPC::Prox);
}

void ANPC::Prox(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{  
    UE_LOG(LogTemp, Warning, TEXT("In Prox"));

}

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [April 25, 2016, 3:26pm UTC](https://forums.unrealengine.com/t/cant-trigger-callback-uspherecomponent-collision/355039/2 "2016-04-25T15:26:31Z")

</div>

Hey SystmShok-

Your setup appears correct, I had the same issue using OnComponentBeginOverlap and have entered a bug report (UE-29879) for investigation. As a workaround, you should be able to use OnActorBeginOverlap() instead, or set up the component overlap through blueprints with an event dispatcher / custom event.

Cheers
