Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to handle RMB and LMB clicks in c++

I need to branch based on if the RMB or LMB is clicked. What is the best way to do this in cpp. I have actions set up for rmb and lmb. One way I thought, would be to write 2 functions for each action that sets a private "is clicked" variable to true or false based on press or release. but that seems like a hassle. I notice that blueprint has a right mouse and left mouse pressed boolean, I was wondering if there is something similar in c++.

Thanks guys, let me know what the best way of handling this is.

Product Version: UE 4.14
more ▼

asked Feb 15 '17 at 06:19 AM in C++ Programming

avatar image

8 3 4 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hi Kekeoki,

You can check if a key is pressed from UPlayerInput::IsPressed(FKey InKey) which returns a boolean.

Hope that helps. Cheers,

more ▼

answered Feb 15 '17 at 09:33 AM

avatar image

1.7k 22 10 49

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hi Kekeoki.

Depending if you have a character or simply a player controller at hand, you want to make sure that

  • an input component is set

  • that you bind to it IE_Pressed and IE_Released actions to a function delegate.

  • that you also set up your input commands in your project settings.

The First person shooter tutorial on the Unreal wiki (https://wiki.unrealengine.com/First_Person_Shooter_C%2B%2B_Tutorial) will provide valuable information, especially the part on Adding Projectiles and Shooting which details how to handle LMB (you can infer RMB handling from it).

If you only have a player controller, it's a bit more tricky, but not too difficult. I shared my struggles with the issue at the end of this post (https://forums.unrealengine.com/showthread.php?109214-Player-controller-input-handling&p=712760&viewfull=1#post712760). Read the Wiki article and then bind your delegates in the same manner after registering the input component.


more ▼

answered Jul 06 '17 at 03:25 AM

avatar image

276 32 37 54

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question