Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?


Product Version: UE 4.18
more ▼

asked Nov 27 '17 at 03:15 PM in C++ Programming

avatar image

5 3 3 5

avatar image MC1RScorpion Nov 27 '17 at 06:34 PM

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.


(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

1) Have you enabled mouse clicks? See:


2) For determining where you clicked in the world, see:


3) so you get world position of the mouse, then if you do


4) and then use the HitResult from the trace, you should get all the information you need.

Hope that helps :) Cheers!

more ▼

answered Nov 27 '17 at 07:17 PM

avatar image

51 3 5

avatar image MC1RScorpion Jan 14 '18 at 12:24 AM

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

Much appreciated.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question