Does anyone know where is the Key Pressed Event of Blueprints is implemented in c++? I want to understand how the engine works when the game is paused, cause i’m using the pause functionality to show some ui messages for the Tutorial section. I want to create a bind in c++ of any key pressed to unpause game and destroy widget. Thank you.
Assuming you already entered the action mappings in “Project >> Engine >> Inputs >> Action Mappings” …
… the bind in C++ is usually in PlayerControllers or Pawns. Code is like this:
void APrimaryPlayerController::SetupInputComponent()
{
ABasePlayerController::SetupInputComponent();
// keyboard action inputs
InputComponent->BindAction("Escape", IE_Released, this, &APrimaryPlayerController::Action_Escape);
InputComponent->BindAction("Use", IE_Released, this, &APrimaryPlayerController::Action_Use);
InputComponent->BindAction("Jump", IE_Pressed, this, &APrimaryPlayerController::Action_Jump);
InputComponent->BindAction("Jump", IE_Released, this, &APrimaryPlayerController::Action_StopJumping);
InputComponent->BindAction("Crouch", IE_Released, this, &APrimaryPlayerController::Action_Crouch);
InputComponent->BindAction("Sprint", IE_Pressed, this, &APrimaryPlayerController::Action_StartSprinting);
InputComponent->BindAction("Sprint", IE_Released, this, &APrimaryPlayerController::Action_StopSprinting);
}
I’m not asking how to bind actions using c++. I’m asking what function in c++ the blueprint event is using. I want to find this function in c++ so i can understand how the kay is handled even when the handle on pause also works. Also there’s a new and better way to setup your binding using Enhanced Input.
Blueprint input action/axis events are custom K2 nodes.
The node you create is a K2Node_InputAction, which internally creates a virtual K2Node_InputActionEvent (among other minor things). That node registers a binding into an internal “UInputDelegateBinding” object, and it’s done for that part.
The rest of it comes from Actor class. Every actor has a potential InputComponent attached to it. That input component is created if you ever use “EnableInput” on the actor. This is obviously automatic for common classes like PlayerController and Character. After creating the input component, the code looks for bindings registered in that “UInputDelegateBinding” object within the blueprint (assuming it was a blueprint). The bindings found there are added to the input component :
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.