Click on player works whereas click on enemy doesn't

I think it’s because the don’t have a controller, see this article:

Hello world again! In my game, I have a class “FightingCharacter” that is a common parent class for Player and Enemy, and I want to display information about their level and health by clicking. What I have done:

  1. I have set up the following blueprint in the class “FightingCharacter”:

  1. I show mouse cursor at game loading.

  2. I have set “Enable click events” in the Player Controller to true.

  3. I have changed “Default click trace channel” at the same place to Camera.

  4. I have tried to set the breakpoint on this event. It works even when I click on self, and is filtered only on condition, but when I click on the Enemy, it does not work.

  5. I have tried to set up ActorOnReleased event on a simple Actor, and it, suddenly, works!

It seems it does not work only on Enemies. What the problem can be?

Who doesn’t have a controller, enemies? They have the AIController. I saw that article but for unknown reason pictures aren’t displayed there, maybe they have been lost in history. Can you point what post of that topic is main for me? Maybe that all input must be in the player controller? But what to do if player has to click on the enemy and not on the player controller?

So, the only normal way is to get hit result under cursor inside the Player Controller, isn’t it?

No, I try to do it in the Player Controller on Left mouse button event, then break hit and cast the hit Actor to FightingCharacter. Or it won’t work?

I can get it to work if I put the code inside the AI controller, but that means they all react at once, unless you incorporate a check to see where the mouse click was…

Yes, you have to do it in the AI controller ( not your player ), but how you know which NPC you clicked, I’m not sure.

That won’t work, because your player controller has nothing to do with the enemies.

I have just tried and it suddenly works! In any way, thanks for answering and good luck!

For those who read this: you probably may check the input in the AIController class, but the good way I found is to check the “Left mouse button” event in the PlayerController, get hit result under cursor, break it and cast the hit Actor to necessary type. Here is my blueprint:

Thanks everybody for the discussion.

a simpler solution would be to check if the hit actor is implementing your “Display Stats” interface and if so send interface message and then handle the display stats in the given actor