Function Delegates and Blueprint Events in C++

Hi,

ENGINE: UE5.0.3

I am trying to run a function in c++ when the event OnBeginCursorOver is fired, but although reading many examples from UE4 and a single post about it in UE5, I can’t get it to work myself.


.h file:

UCLASS()
class MyGame_API AMob : public ACharacter
{

public:
UFunction()
void MyFunction();
}

.cpp

AMob::AMob()
{

FScriptDelegate x;
x.BindUFunction(this, “MyFunction”);
OnBeginCursorOver.Add(x);

… …
GetMesh()->OnBeginCursorOver.Add(x);
}

AMob::MyFunction()
{
UE_LOG(LogTemp, Warning, TEXT(“WOOOOO IT WORKS!!”));
}


I added function delegates for the OnBeginCursorOver for the SkeletalMesh and for the Actor object, but MyFunction is never executed once.

And I do have “Enable Mouse Over Events” set to true, and I tested that it works for other basic objects when mousing over them. I just want to avoid using blueprints as I prefer c++.

Any help is appreciated. :slight_smile:

From an old UE4 post it seems that in order to enable mouse over events for Actors, they need a “static mesh component”… So a temporary fix for now is to make a static mesh e.g. a cylinder that somehow fits the skeletal mesh model, and then making it invisible.

I am not impressed with this solution myself.

Does anyone know why mouseover events do not work for skeletal meshes?