How to implement right mouse button on actor click

Hi, I am trying to create a building system for a pawn to place buildings, I have it mostly working, I can place buildings, but I am trying to make a cancel action with right mouse button.

This is not working, but to visualise what I’m trying to achieve;

I realise now after reading online that the Event ActorOnClicked is “only” for left mouse button - but is there any simple way to achieve what I’m trying to do?

In the player controller:

Now you can also do onClick for RMB.


But the whole clicking thing should be done in the Player Controller tbh. Consider it. You intercept / handle the click in one place and send the target actor / component an interface message. That entity then interprets what the message means. The interface can still be implemented in the base class children inherit behaviour from and / or override it.

6 Likes

Thank you!

I will keep the interface thing in mind, but this is my first go at my own UE game, I’m sure when I get more experience in such things I’ll find the correct methods.

By chance do you have any suggestions on any learning material for the interfaces?

  • lets say this is my actor and two child classes:

  • the interface :point_up_2: the base myActor class implements :point_down:

  • in the player controller:

  • the inheriting classes can:

image

The above is just the tip of the ice-berg, ofc. Worth exploring, there’s no turning back once you wrap you mind around this.

Don’t get me wrong. The onClick you attempt can get you far but, at some point, it may not be sufficient once more complex scenarios become awkward to handle.


Tuts, YT has plenty, not sure what to recommend to be honest:

https://www.youtube.com/results?search_query=ue+interface+comms

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.