- The engine internally tracks what keyboard keys and mouse buttons have been pressed and released.
- The “input mappings” in Project Settings map these input keys and buttons to named actions. This is extremely useful, because you do not have to hard-code “left shift” or “right mouse button”, you can just refer to the “Grab” action. By default, that action is associated with the left shift and the right mouse button, but it is easy to change that in the Project Settings, and it even allows the players themselves to configure the mappings in some input configuration menu in runtime inside the game.
-
Input->BindAction(TEXT("Grab"), IE_Pressed, this, &UGrabber::Grab);
Input->BindAction(TEXT("Grab"), IE_Released, this, &UGrabber::Release);
Above, you register callbacks for the named action with the Input Component. Basically, the engine will internally let the Input Component know when the “Grab” action is pressed and released. And the BindAction() calls above tell the Input Component “hey, when the “Grab” action is pressed, I want you to call the UGrabber::Grab() function, and when the “Grab” action is released, I want you to call the UGrabber::Release() function”.