x

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"

Capture left/right mouse click globally

Hi,

I have a problem with mouse click (left or right). I take an example from the sample "Puzzle". One different is that I need capture mouse click from Pawn (witch is connected to PlayerController) no matter what was clicked. (In sample puzzle blocks are "clickable" by its geometry, but in my idea there is no "geometry").

I want capture click on screen and create object in this position, but I stuck at capture left click, I can get mouse coordinates from Pawn but not the click event. Position I'm getting form Pawn::Tick function.

[UPDATE] Im using this->OnClicked.AddDynamic(this, &ATouchTestPawn::MouseClick) from Pawn constructor. Im binding InputComponent->BindAction("TriggerClick", EInputEvent::IE_Pressed, this, &ATouchTestPawn::TriggerClick) from Pawn::SetupPlayerInputComponent but delegate is not called.

Product Version: UE 4.13
Tags:
more ▼

asked Oct 12 '16 at 03:20 PM in C++ Programming

avatar image

LUKASZJB
28 4 6 10

avatar image LUKASZJB Oct 13 '16 at 02:19 PM

[Update]
Maybe someone see this as useful.
In "mobile" project you need using InputComponent->BindTouch instead InputComponent->BindAction

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

1 answer: sort voted first

Have you tied your "TriggerClick" action to the left mouse button?

You can do this in the editor in the Project Settings window. Under Engine->Input, there's a Bindings panel.

You can also do this in code by collecting the UInputSettings object and adding an AxisMapping or ActionMapping (for a click event you would use ActionMapping).

 UInputSettings* InputSettings = const_cast<UInputSettings>(GetDefault<UInputSettings>());
 if (InputSettings) {
     
     //create action mapping
     FInputActionKeyMapping NewMapping = FInputActionkeyMapping();
     NewMapping.ActionName = "TriggerClick";
     NewMapping.Key = FKey("LeftMouseButton");
     NewMapping.bShift = false;
     NewMapping.bCtrl = false;
     NewMapping.bAlt = false;
     NewMapping.bCmd = false;
 
     //add to input settings
     InputSettings->AddActionMapping(NewMapping);
 
 }

You can also manually add the action mapping in your Input.ini file.

See:

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

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/FInputActionKeyMapping/index.html

https://docs.unrealengine.com/latest/INT/API/Runtime/InputCore/FKey/index.html

https://wiki.unrealengine.com/List_of_Key/Gamepad_Input_Names

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/UPlayerInput/index.html

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/UPlayerInput/AddActionMapping/index.html

more ▼

answered Oct 12 '16 at 09:43 PM

avatar image

GigasightMedia
1.7k 43 14 61

avatar image LUKASZJB Oct 13 '16 at 12:06 PM

Thanks for help, now it's working.

Solved.

(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