# How to detect object on mouse click

**URL:** <https://forums.unrealengine.com/t/how-to-detect-object-on-mouse-click/290812>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [August 12, 2014, 9:35pm UTC](https://forums.unrealengine.com/t/how-to-detect-object-on-mouse-click/290812 "2014-08-12T21:35:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_6169790a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6169790a](https://forums.unrealengine.com/u/anonymous_user_6169790a)\
**Post date:** [August 12, 2014, 9:35pm UTC](https://forums.unrealengine.com/t/how-to-detect-object-on-mouse-click/290812/1 "2014-08-12T21:35:03Z")

</div>

Hey Guys! I’m pretty new to UE. I’m just playing around with top down template.

I created my own player controller and set the right mouse click to move the player. Its working fine. I tried creating a left mouse click event to select the player and show its name in the log message. I tried using “Get hit result under cursor by channel” but it didn’t work.

Please tell me how to detect the different objects the mouse is clicked on.  
Thank You.

---

<div class="post-metadata">

**Author:** ![Jurif](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jurif](https://forums.unrealengine.com/u/Jurif)\
**Post date:** [August 13, 2014, 12:49am UTC](https://forums.unrealengine.com/t/how-to-detect-object-on-mouse-click/290812/2 "2014-08-13T00:49:53Z")

</div>

Hi, well one easy way would be to add a box to the player-character blueprint, you could use a static mesh ,  
than add events to static mesh, process would be something like this:

1. Import a Static Mesh and name it, then right click–\> Copy Reference !  
2.Go to your Blueprint , in the “Components” tab click “Add Component” and select “Static Mesh”, in the settings for Static Mesh Component paste the reference to your imported mesh.
2. A little lower find the “Events” section rollout, there click and select what you want , for example “On touch”, “On Click” , and add the functionality in the graph.
3. The last thing would be to make the Static Mesh invisible, one way to do that would be to simply un-check the “visible” parameter in the Rendering rollout or you could apply an invisible material to it, create a material and try Mask mode and give a black color or small black texture to the “Opacity Mask” slot.

Then you could also cast your Gamemode blueprint to player character blueprint and store the reference in a variable. So you could trigger nodes and functions in the gamemode blueprint. Something like this(just an example from my project):

 ![12574-screenshot267.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/5/3/0533c392095061288ae09a2f947d6cabfa8be860.jpeg)

 ![12575-screenshot266.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/f/7/9f776440ad35fc49c6f1c9e4f25854a4d53d7b21.jpeg)

The other way would be to iterate through actors and search for what you have clicked on, doing line trace or using for each loops or iterator functions in code.
