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.
asked Feb 15 '17 at 06:19 AM in C++ Programming
You can check if a key is pressed from
Hope that helps. Cheers,
answered Feb 15 '17 at 09:33 AM
Depending if you have a character or simply a player controller at hand, you want to make sure that
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.
Follow this question
Once you sign in you will be able to subscribe for any updates here