# Right click on an actor

**URL:** <https://forums.unrealengine.com/t/right-click-on-an-actor/299218>\
**Category:** Character & Animation\
**Tags:** right-click, unreal-engine, onclicked, Blueprint, question\
**Created:** [November 17, 2014, 10:13pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218 "2014-11-17T22:13:01Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![alucarders](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@alucarders](https://forums.unrealengine.com/u/alucarders)\
**Post date:** [November 17, 2014, 10:13pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/1 "2014-11-17T22:13:01Z")

</div>

Hi!

I’m trying to implement OnClicked event for an actor but for the right mouse button. I didn’t find anything in unreal events and didn’t manage to create one. So I just want some basics: a player presses right button on an static mesh and a Print String function is called. Any help would be appreciated 🙂

Thanks

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [November 17, 2014, 10:23pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/2 "2014-11-17T22:23:43Z")

</div>

Hey -

There are actually a couple of ways to setup a right mouse button click event. You can right click in the blueprint graph and directly add a “Right Mouse Button” event that will trigger when the right mouse button is either pressed or released. Alternatively, in the Edit-\>Project Settings menu under the Engine heading you can select Input. Here you can set up an action mapping for the right mouse button and give the mapping a unique name (ClickMe for example). Then in your blueprint add an event node for the ClickMe event. This method is preferred if the game is going to be for more than one system (“Press jump to jump” rather than “Press space to jump”).

Cheers

---

<div class="post-metadata">

**Author:** ![alucarders](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@alucarders](https://forums.unrealengine.com/u/alucarders)\
**Post date:** [November 17, 2014, 10:33pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/3 "2014-11-17T22:33:25Z")

</div>

> in the Edit-\>Project Settings menu under the Engine heading you can select Input. Here you can set up an action mapping for the right mouse button and give the mapping a unique name

I’ve already tried this but it didn’t help.

![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/9/c/09c67874ff7d5f513f6ae0a585bcd3f57c2e77de.png)  
Maybe I need to somehow get an actor first?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [November 17, 2014, 10:55pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/4 "2014-11-17T22:55:56Z")

</div>

In your screenshot you are using an axis mapping. What you want to use instead is the “Action Mappings” which is above Axis Mapping.

---

<div class="post-metadata">

**Author:** ![alucarders](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@alucarders](https://forums.unrealengine.com/u/alucarders)\
**Post date:** [November 17, 2014, 11:01pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/5 "2014-11-17T23:01:21Z")

</div>

Okay, I’ve remapped right button click to actions.

[](https://i.imgur.com/oBe4A8q.png)

And now the left click works but the right click still doesn’t.

---

<div class="post-metadata">

**Author:** ![Justin.Dooley](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justin.dooley/32/1194553_2.png) [@Justin.Dooley](https://forums.unrealengine.com/u/Justin.Dooley)\
**Post date:** [November 17, 2014, 11:11pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/6 "2014-11-17T23:11:28Z")

</div>

The player controller does have a **Right Mouse Button Event**. Just get hit result under cursor for object.

---

<div class="post-metadata">

**Author:** ![alucarders](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@alucarders](https://forums.unrealengine.com/u/alucarders)\
**Post date:** [November 18, 2014, 9:32am UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/7 "2014-11-18T09:32:45Z")

</div>

Can you draw an example, please?

---

<div class="post-metadata">

**Author:** ![eXi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/exi/32/906583_2.png) [@eXi](https://forums.unrealengine.com/u/eXi)\
**Post date:** [November 18, 2014, 1:32pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/8 "2014-11-18T13:32:42Z")

</div>

If you setup the “Action Mapping” like told you, you would need to make sure that the Input is enabled for that BP.

The CharacterBP should be enabled by default, but if you want other BP to accept rightclick you would need to enable it’s input:

[http://puu.sh/cVMUT/e49a865792.png](http://puu.sh/cVMUT/e49a865792.png)

But this is not what you want, because now you can just rightclick everywhere and it would print “Hello”.

So better get the Hitresult under Cursor and do your stuff depending on the hitresult. Here i just printed the Hitactors Name. Maybe you should also use a branch and plugin the “Return Value” which is just true or false depending on hitting something at all.

[http://puu.sh/cVNbN/e25d117135.png](http://puu.sh/cVNbN/e25d117135.png)

---

<div class="post-metadata">

**Author:** ![alucarders](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@alucarders](https://forums.unrealengine.com/u/alucarders)\
**Post date:** [November 18, 2014, 2:26pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/9 "2014-11-18T14:26:32Z")

</div>

Thanks for your reply! I’ve finally managed to get desired functionality, but now I got the last question 🙂

I’ve made an interaction according to your advice and now it looks like this:

[](https://i.imgur.com/eVjAUgp.png)

Is there any other way to compare hit results? Now I just take the result and then compare it with the hardcoded string (Actor\_Name\_Blueprint). I wonder if it’s correct way to do so?

---

<div class="post-metadata">

**Author:** ![eXi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/exi/32/906583_2.png) [@eXi](https://forums.unrealengine.com/u/eXi)\
**Post date:** [November 18, 2014, 2:29pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/10 "2014-11-18T14:29:52Z")

</div>

You want to compare one hit result with a second one? Make a variabel of type actor. Check with “Is Valid” if it’s NULL. If Is Valid is False, set the Hitresult Actor to this Variable. If it’s not NULL Compare the new result with the variable. After that, set the variable back to NULL.

---

<div class="post-metadata">

**Author:** ![alucarders](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@alucarders](https://forums.unrealengine.com/u/alucarders)\
**Post date:** [November 18, 2014, 3:29pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/11 "2014-11-18T15:29:14Z")

</div>

No, I must have been misunderstood 🙂

I have an actor in the level (a button) and I want to add right click event on this button. As far as I couldn’t find any simple solutions (like Event Actor On Clicked for the left mouse button click), I’ve made a solution as shown above. It works only if Hit Actor Display Name equals to the button name. So actually I asked if there is any other way to detect when right button is clicked only on particular actor (button in my example).

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [November 18, 2014, 3:55pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/12 "2014-11-18T15:55:04Z")

</div>

Hey -

The nodes “Event Actor Begin Cursor Over” and “Event Actor End Cursor Over” can be used to tell if the mouse cursor is currently overlapping the object (your button). Then you can use the a pair of branch nodes to check if the mouse is over the object and being pressed. The following image is for moving an object upward only when the mouse is clicking it but it shows the nodes you would use and how to set them up.

---

<div class="post-metadata">

**Author:** ![eXi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/exi/32/906583_2.png) [@eXi](https://forums.unrealengine.com/u/eXi)\
**Post date:** [November 18, 2014, 4:05pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/13 "2014-11-18T16:05:11Z")

</div>

Hm ok.

So your button 100% needs to be clicked? You can make a Sphere Collider in the Button Blueprint and the OnOverlapBegin event could enable input. OnOverlapEnd would be used to disable input. This is just a sidenode.

Ok back to your problem. You should have a function inside your ButtonBP.

So try casting the Hit Actor to the Button Blueprint and from the return value of the cast, drag out the function and call it. It will call the function on the button you pressed.

---

<div class="post-metadata">

**Author:** ![alucarders](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@alucarders](https://forums.unrealengine.com/u/alucarders)\
**Post date:** [November 18, 2014, 4:19pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/14 "2014-11-18T16:19:56Z")

</div>

Thank you !

Now I have a solution that suits my needs and looks very pretty 🙂

---

<div class="post-metadata">

**Author:** ![eXi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/exi/32/906583_2.png) [@eXi](https://forums.unrealengine.com/u/eXi)\
**Post date:** [November 18, 2014, 4:28pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/15 "2014-11-18T16:28:01Z")

</div>

Ok, i mark this question as resolved for you. In other questions please click the check mark at the left side of the answer to mark the questions as solved by yourself.

---

<div class="post-metadata">

**Author:** ![MMolnar85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MMolnar85](https://forums.unrealengine.com/u/MMolnar85)\
**Post date:** [December 1, 2022, 6:58pm UTC](https://forums.unrealengine.com/t/right-click-on-an-actor/299218/16 "2022-12-01T18:58:28Z")

</div>

Hey,

I have been struggling with the same topic and I have the following solution that might be helpful to someone as well:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/1/8/f189663bb8dbb05b116987de80f11cbe94c0c50f.png)
