OnClicked.AddDynamic Not Executing Function


I’m new to Unreal Engine and C++ and am currently trying to get a UE_Log to print when I click my default pawn.

I’ve added this function to my pawn’s .H which inherits from APawn.

    void OnSelected(AActor* ClickedActor, FKey ButtonPressed);

I’ve also added the following to the corresponding .CPP in the constructor.

OnClicked.AddDynamic(this, &AMossyRock01::OnSelected);

Here is the function in the same .CPP that I expect OnClicked.AddDynamic to call.

void AMossyRock01::OnSelected(AActor* ClickedActor, FKey ButtonPressed)
    UE_LOG(LogTemp, Warning, TEXT("Pawn selected"));

Alas, although the code compiles, the log is never printed no matter how I click the pawn in the game. Can anyone help me?


To be clear, what I’m hoping to do is “grow” static meshes on the object I’m clicking at the point where I’ve clicked it. I thought I could do this by ray tracing from the cursor to the object and then using the EndTrace value as the spawning point for objects I’m growing. Unfortunately I’ve had little luck finding much information on tracing from the cursor, firing functions off on clicks, etc.

Any help with these subjects would be much appreciated.


  1. Have you enabled mouse clicks? See:


  1. For determining where you clicked in the world, see:
  1. so you get world position of the mouse, then if you do
  1. and then use the HitResult from the trace, you should get all the information you need.

Hope that helps :slight_smile:

At the time I was struggling with this, your advice helped a lot. Thank you.

Much appreciated.