I’m having trouble figuring out how to handle click events for an Actor mesh in c++ code.
Everything is set up in the editor, I can add a onclick event to the mesh in the blueprint and it works fine with my planned logic, but I want to have this in the code.
I looked around and found this: OnClicked Parameters - Programming & Scripting - Unreal Engine Forums
However I am not having any luck with my method being triggered.
cpp file
AShipActor::AShipActor(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer){
ShipMesh = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("ShipMesh"));
ShipMesh->AttachTo(RootComponent);
ShipMesh->OnClicked.AddDynamic(this, &AShipActor::OnClicked);
};
void AShipActor::OnClicked(UPrimitiveComponent* pComponent){
//my logic
}
Any help would be greatly appreciated!
Thanks