0
\$\begingroup\$

Summarizing my problem well, I need a single button (right mouse button) to do two things.

In my project (TopDown) I defined that instead of the left mouse button, the character moves with the right mouse button.

I happen to like that when I click the right mouse button on a particular actor, a simple event is called (print hello).

I tried doing this with the Event On Clicked, but it only works with the left mouse button:

enter image description here

enter image description here

With the help of these links:

https://www.unrealengine.com/en-US/blog/input-action-and-axis-mappings-in-ue4

https://answers.unrealengine.com/questions/134349/right-click-on-an-actor.html

https://answers.unrealengine.com/questions/17729/how-to-create-a-right-mouse-click-event-with-bluep.html

I figured out how to do an action/event call with the right mouse button, but even then I did not succeed.

Soon I discovered that the reason was that there was already an action that was executed with the right mouse button (walk/set destination):

enter image description here

I would like my character to continue to move with the right click of the mouse, but how do I also call an event when I click the right mouse button?


EDIT 1

If the mapping is done with two different keys, it works perfectly:

enter image description here

In this case the character jumps and walks (instead of jumping it could be anything else):

enter image description here

I want this to happen by right-clicking (walking and jumping):

enter image description here

This action I want to perform is when clicking on the mesh of any actor, but I can only do this with the left button.

\$\endgroup\$
  • \$\begingroup\$ If UE4 cant direct the same mapping to 2 actions you should do it manually - make one mapping e.g OnRMB - and then call both of your actions manually from the OnRMB \$\endgroup\$ – ColdSteel Jul 4 at 2:44
  • \$\begingroup\$ @ColdSteel could you send me the link for some example of this? \$\endgroup\$ – Boneco Sinforoso Jul 4 at 21:18
1
\$\begingroup\$

If you only want the RMB to trigger the event, then use the "Button Pressed" pin from the OnClicked method to check if it's a right-click or not before continuing.

You can also use GetEffectingButton and do a check to see if its RMB as illustrated here.

EDIT:

So you want two different possible actions to occur with the exact same input?

Then you won't be able to have two different action mappings, because as far as Unreal is concerned, its the same input, unless you have a modifier like Alt, Shift, etc. You'll have to do the check on your end.

I would suggest tagging the possible static meshes that can be clicked and then checking the tag of the touched object. For example, tag the terrain they can walk on with 'terrain' and the characters/items they can access a context menu with 'context'. Then call custom functions depending on which tag you find when they click.

(From a design standpoint, I do not recommend having movement and context menu on same input. Look at League & DOTA, the most popular top-down games. Movement is RMB, inspect & interact is LMB. Otherwise you can have accidental movement when a player is just trying to look.)

\$\endgroup\$
  • \$\begingroup\$ In Button Pressed pin nothing appears on the right mouse button. \$\endgroup\$ – Boneco Sinforoso Jul 3 at 23:13
  • \$\begingroup\$ I did not find the function (OnMouseButtonDown), even looking for Override Functions. This is because I want to apply the click to an actor, not to a widget. \$\endgroup\$ – Boneco Sinforoso Jul 3 at 23:25
  • 1
    \$\begingroup\$ If this is not a widget I discourage using the OnClicked in graph - it will not allow for easy key binding later on. \$\endgroup\$ – ColdSteel Jul 4 at 2:45
0
\$\begingroup\$

To solve my problem I would have to know how to modify the Input Action Set Destination, or simply reproduce what the Input Action Set Destination does.

With the help of this question (which I was able to answer, it was a simple mistake) I was able to figure out how to make the character walk based on the mouse click:

https://answers.unrealengine.com/questions/260158/making-a-top-down-mouse-following-character.html?childToView=910918#answer-910918

Just create an Action Mapping:

enter image description here

Using the code below you can get the character to go to the mouse click (ignore the pink circles, I re-used the image):

enter image description here

Based on the previous code, it was only me that added a condition based on the actor that was clicked:

enter image description here

In the future this condition will be something involving the floor of the level, but for the answer I used the tower and inverted logic.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.