OnBeginCursorOver not working, C++ & mouse hover

I had a lot of problems getting OnBeginCursorOver to fire in my Actor subclass in C++. I tried a lot of different approaches on various posts and nothing worked.

Commenting here because this post has had a lot of views and other posts I found expressed similar frustrations.

In the end this worked for me. Turn it on in the APlayerController subclass:

AAdventurePlayerController::AAdventurePlayerController()
{
	SetShowMouseCursor(true);
	bEnableMouseOverEvents = true;
}

…then in the static mesh actor:

void AHotSpot::BeginPlay()
{
	UStaticMeshComponent* StaticMeshComponent = GetStaticMeshComponent();
	if (StaticMeshComponent && StaticMeshComponent->GetStaticMesh())
	{
		StaticMeshComponent->SetCollisionEnabled(ECollisionEnabled::Type::QueryOnly);
		StaticMeshComponent->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Overlap);
		StaticMeshComponent->SetGenerateOverlapEvents(true);

		Super::OnBeginCursorOver.AddDynamic(this, &AHotSpot::OnBeginCursorOver);
		Super::OnEndCursorOver.AddDynamic(this, &AHotSpot::OnEndCursorOver);
	}
}

I did same as you @Ettu_R - with the SetCollisionResponseToChannel but my handlers were messed up (see below).

I also added the line above to set QueryOnly collisions enabled and also SetGenerateOverlapEvents to true.

I also moved the binding of the callbacks to after these flags were set up, just in case.

One thing to note is that the naming of the callback is arbitrary. I had gotten the impression that just naming it that OnBeginCursorOver would work, but of course it doesn’t. You have to bind handlers with these signatures:

	//////////////////////////////////
	///
	/// USER INPUT EVENTS
	///

	UFUNCTION(BlueprintCallable, Category = "HotSpot")
	void OnBeginCursorOver(AActor *TouchedActor);

	UFUNCTION(BlueprintCallable, Category = "HotSpot")
	void OnEndCursorOver(AActor *TouchedActor);

I’m not sure if other handlers with the UPrimitiveComponent argument ever worked. That was what I had before arriving at this.