Unresponsive InputTouchBegin Delegate in C++

Hi,

I am having trouble with binding functions to the InputTouchBegin event for an AActor and it’s UPrimitiveComponent.

Header:

UFUNCTION()
void OnComponentTouchBegin(ETouchIndex::Type FingerIndex, UPrimitiveComponent* TouchedComponent);

UFUNCTION()
void OnActorTouchBegin(ETouchIndex::Type FingerIndex, AActor* TouchedActor);

Constructor:

Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh Component"));
if (Mesh) {
    RootComponent = Mesh;
    Mesh->OnInputTouchBegin.AddDynamic(this, &ACustomActor::OnComponentTouchBegin);
}
this->OnInputTouchBegin.AddDynamic(this, &ACustomActor::OnActorTouchBegin);

All of the respective Project / Player Controller touch input settings are enabled. I have confirmed this by running the code in blueprint first (below).

Hey all,

This one actually had a very simple solution - move the binding code to BeginPlay() instead of the constructor.

This is a bit odd to me because I’ve always seen delegates in the constructor. Either way, it works!

Cheers,
Kevin