# CPP VIVE Controller OnComponentHit doesn't fire

**URL:** <https://forums.unrealengine.com/t/cpp-vive-controller-oncomponenthit-doesnt-fire/362146>\
**Category:** XR Development\
**Tags:** oncomponenthit, oncomponentbeginover, Vive, unreal-engine, CPP, question\
**Created:** [June 27, 2016, 11:21am UTC](https://forums.unrealengine.com/t/cpp-vive-controller-oncomponenthit-doesnt-fire/362146 "2016-06-27T11:21:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_1aa4840c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1aa4840c](https://forums.unrealengine.com/u/anonymous_user_1aa4840c)\
**Post date:** [June 27, 2016, 11:21am UTC](https://forums.unrealengine.com/t/cpp-vive-controller-oncomponenthit-doesnt-fire/362146/1 "2016-06-27T11:21:34Z")

</div>

I followed this tutorial:[UE4 c++ OnComponentOverlap and OnComponentHit syntax - YouTube](https://www.youtube.com/watch?v=NAbLfvTJLrw)

And used this to create a sphere that triggers hits and overlap events in my scene, this works perfectly. I then tried to apply the same principal and attach the sphere to a vive UMotionController component, where the OnComponentBeginOverlap works but OnComponentHit will not.

VR\_Pawn.h:

```
// Motion Controllers
UPROPERTY(EditDefaultsOnly, Category = "Components")
UMotionControllerComponent* LeftHandComponent;

UPROPERTY(EditDefaultsOnly, Category = "Components")
UMotionControllerComponent* RightHandComponent;

UPROPERTY(EditAnywhere)
USphereComponent* ControllerCollision;

UFUNCTION()
void OnControllerHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);

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

```

VR\_Pawn.cpp

```
void AVR_Pawn::OnControllerOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult){
UE_LOG(LogTemp, Warning, TEXT("CONTROLLER OVERLAP!"));
}

void AVR_Pawn::OnControllerHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit) {
UE_LOG(LogTemp, Warning, TEXT("CONTROLLER HIT!!"));
}

AVR_Pawn::AVR_Pawn(const FObjectInitializer& objectInitalizer)
:Super(objectInitalizer)
{
PrimaryActorTick.bCanEverTick = true;
BaseEyeHeight = 0.f;

DefaultSceneRoot = CreateDefaultSubobject<USceneComponent>(TEXT("DefaultSceneRoot"));
DefaultSceneRoot->SetupAttachment(RootComponent);

Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
Camera->SetupAttachment(DefaultSceneRoot);

SetActorEnableCollision(true);

LeftHandComponent = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("LeftHand"));
LeftHandComponent->Hand = EControllerHand::Left;
LeftHandComponent->SetupAttachment(DefaultSceneRoot);

ControllerCollision = CreateDefaultSubobject<USphereComponent>(TEXT("RootCollision"));
ControllerCollision->SetupAttachment(LeftHandComponent);
ControllerCollision->SetSphereRadius(20.f);
ControllerCollision->SetHiddenInGame(false);
// **WORKS**
ControllerCollision->OnComponentBeginOverlap.AddDynamic(this, &AVR_Pawn::OnControllerOverlap);
// **DOESN'T WORK**
ControllerCollision->OnComponentHit.AddDynamic(this, &AVR_Pawn::OnControllerHit);
}

```

The LeftHandComponent & ControllerCollision are set to BlockAll with simulation generates hit events ticked.

I left the other sphere I created in the tutorial in the scene, and its hit function fires when the controller enters it, but the controllers hit does not fire.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1aa4840c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1aa4840c](https://forums.unrealengine.com/u/anonymous_user_1aa4840c)\
**Post date:** [November 9, 2017, 7:11pm UTC](https://forums.unrealengine.com/t/cpp-vive-controller-oncomponenthit-doesnt-fire/362146/2 "2017-11-09T19:11:51Z")

</div>

Coming back to this. I solved it by removing all the overlap code, closing unreal, regenerating the VS projects files, clean and build and it worked. Something was lingering from the build overlap code but I could not find it.
