Why is ReceiveActorOnClicked not fired?

Hi I’ve tried to find out how to handle a simple click on an Actor. I have a player controller with this (default) constructor:

AMyPlayerController::AMyPlayerController(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
	bShowMouseCursor = true;
	bEnableClickEvents = true;
	bEnableTouchEvents = true;
	DefaultMouseCursor = EMouseCursor::Crosshairs;
}

so the bEnableClickEvents is set. I also checked if this is indeed the player controller that is used.

In the actor (which has a basic cube as the root object) I add in the header (public) a

void ReceiveActorOnClicked();

and in the c++ file I define the function and print a log message. But it is never fired. I run the game in the editor (that worked with mouse clicks right?)
I can’t find out what I’m missing. Can anyone help me out? thanks!

Hi BramV,

The problem that you’re encountering is due to virtual functions and overriding existing virtual functions. As with BeginPlay(); ReceiveActorOnClicked() is an existing function that must be called as a virtual function and overidden if you want to modify what the function does in your .cpp file

virtual void ReceiveActorOnClicked() override;

Using this syntax in your .h file will allow you to place the code of your choosing into the definition of the function. If this doesn’t work however, please let me know and I’ll look into the issue further.

Have a nice day,

Thanks for the answer, in my case it also had to do with the fact that I had started the project as a mobile game, so when I click with the mouse a touch event is generated and not an onclick event.