Ninja Bear Studio Plugins Help

Input Handlers

Input Handlers are responsible for handling Player Inputs. They are mapped to Input Actions, bundled into an Input Setup and then triggered by the Input Manager.

Input Handler Design

Input Handlers extend from NinjaInputHandler, which grants them the following default properties. You can also extend any other handler provided by the framework, to modify its default behavior.

Property

Description

Input Actions

Input Actions compatible with the Input Handler.

Trigger Events

For each provided action, which Trigger Events will be detected.

Can Be Buffered

Allows the Input Handler to be buffered .

Input Handlers also contain the following relevant functions.

Function

Description

Can Handle

Determines if the Handler is compatible with an Input Action and Input Trigger.

Handle

Multiple Handle functions are available, each matching a specific input trigger event.

The CanHandle check is purely a compatibility check and should not include temporary states. As for the Handle functions, you only need to implement the ones that are actually used by your handler.

Both functions are marked as const, since the Input Handler is not supposed to have a state. If a state is required, then it should be persisted somewhere else, such as the Player Controller or Character.

Creating Input Handlers

Input Handlers can be created from the NinjaInputHandler class, or any other Handler class available in the system that better suits your needs. Handlers can be created in Blueprints or in C++.

Creating an Input Handler

  1. In your Content Browser, create a new Input Handler, by selecting this option in the Ninja Bear Studio context menu.

    Creating Input Handlers
  2. Name your Handler and navigate to the Class Defaults panel.

  3. Set the Input Actions and Trigger Events that are compatible with the new Input Handler.

  4. Navigate to the Class Settings panel and provide the correct Blueprint Display Name.

  5. In the list of Functions, select the functions that are relevant to your Handler and implement them as needed.

    Creating Input Handlers

Overrideable Functions

Input Handlers have multiple Handle functions, relative to each one of the main input events triggered by the Enhanced Input framework.

  • Started: An input action has started but have not yet triggered. "Started" and "Triggered" may happen during the same frame.

  • Triggered: An input action was triggered. The moment when this happens depends on the type of trigger set in the Input Action. For example, the " Pressed " trigger will send this event as soon as the actuation happens.

  • Ongoing: An input action has been triggered, and it is still ongoing. For example, the " Down " trigger will send this event while the tracked button is pressed.

  • Completed: An input action has been fully handled. "Completed" and "Triggered" may happen during the same frame.

  • Cancelled: An input action has started, but was interrupted before reaching the "Triggered" event.

You can determine whether a key was pressed or released with the appropriate Pressed and Released Input Action Triggers. They provide appropriate true and false values that you can use. You can convert the value provided by the Handler to a boolean, using the conversion functions provided by the Enhanced Input library.

Boolean Conversion

The following image shows a custom Input Handler and some strategies to access contextual data from it, like the player, controller and input values.

Handler Function Example

Here is a breakdown of each input parameter available in the function's signature:

  • Manager: The Actor Component assigned to the owning character invoking this handler. You can access your Player Pawn, Controller and Ability System Component from this component.

  • Value: Final Action value to be applied to the owning character. Make sure to access the value in a way that is coherent with the Input Action value type.

  • Input Action: Additional information about the Input Action that triggered this handler.

  • Elapsed Time: Total time the action has been evaluating triggering. Only relevant/available for Ongoing and Triggered events.

Compatibility Checks

Handlers need to determine if they are compatible with an action or not. This can be done via the CanHandle function.

The default handler already provides a behavior that checks if the Input Handler is compatible with the Input Action and Trigger Event, which are defined by the Handler's default properties, InputActions and TriggerEvents.

The following image shows an additional check for a custom Input Action Data Asset that may contain project-specific information, that could even be used in the test itself.

Check Function Example

Input Handler Examples

Here are some examples of Input Handlers, written in both Blueprints and C++ with some common use-cases.

Movement Handler

To move a pawn (or character), you just need to add the incoming input value to the proper world directions. This is meant to be used only as a reference, since the framework already provides a more robust Move Input Handler.

Move Example
// Ninja Bear Studio Inc., all rights reserved. #pragma once #include "CoreMinimal.h" #include "NinjaInputHandler.h" #include "UInputHandler_MoveSample.generated.h" UCLASS(meta = (DisplayName = "Sample: Move")) class PLUGINLABS_API UInputHandler_MoveSample : public UNinjaInputHandler { GENERATED_BODY() public: UInputHandler_MoveSample(); protected: virtual void HandleOngoingEvent_Implementation(UNinjaInputManagerComponent* Manager, const FInputActionValue& Value, const UInputAction* InputAction, float ElapsedTime) const override;

// Ninja Bear Studio Inc., all rights reserved. #include "InputHandlers/InputHandler_MoveSample.h" #include "InputAction.h" #include "Components/NinjaInputManagerComponent.h" #include "GameFramework/Pawn.h" UInputHandler_MoveSample::UInputHandler_MoveSample() { TriggerEvents.Add(ETriggerEvent::Ongoing); } void UInputHandler_MoveSample::HandleOngoingEvent_Implementation(UNinjaInputManagerComponent* Manager, const FInputActionValue& Value, const UInputAction* InputAction, float ElapsedTime) const { APawn* Pawn = Manager->GetPawn() FVector2D InputValue = Value.Get<FVector2D>(); InputValue = InputValue.GetSafeNormal(); const FVector ForwardDirection = Manager->GetForwardVector(); Pawn->AddMovementInput(ForwardDirection, InputValue[1]); const FVector RightDirection = Manager->GetRightVector(); Pawn->AddMovementInput(RightDirection, InputValue[0]); }

Look Handler

To control the camera assigned to a pawn, you can add the incoming input to the Controller's Pitch and Yaw inputs. Once again, this is meant to be used only as a reference, since the framework provides a more robust Look Input Handler.

Look Example
// Ninja Bear Studio Inc., all rights reserved. #pragma once #include "CoreMinimal.h" #include "NinjaInputHandler.h" #include "UInputHandler_LookSample.generated.h" UCLASS(meta = (DisplayName = "Sample: Look")) class PLUGINLABS_API UInputHandler_LookSample : public UNinjaInputHandler { GENERATED_BODY() public: UInputHandler_LookSample(); protected: virtual void HandleOngoingEvent_Implementation(UNinjaInputManagerComponent* Manager, const FInputActionValue& Value, const UInputAction* InputAction, float ElapsedTime) const override;

// Ninja Bear Studio Inc., all rights reserved. #include "InputHandlers/InputHandler_LookSample.h" #include "InputAction.h" #include "Components/NinjaInputManagerComponent.h" #include "GameFramework/Pawn.h" UInputHandler_LookSample::UInputHandler_LookSample() { TriggerEvents.Add(ETriggerEvent::Ongoing); } void UInputHandler_LookSample::HandleOngoingEvent_Implementation(UNinjaInputManagerComponent* Manager, const FInputActionValue& Value, const UInputAction* InputAction, float ElapsedTime) const { APawn* Pawn = Manager->GetPawn() FVector2D InputValue = Value.Get<FVector2D>(); Pawn->AddControllerYawInput(InputValue[0]); Pawn->AddControllerPitchInput(InputValue[1]); }

Crouch Handler

This example makes a character crouch and stand up, using Pressed and Released triggers. It's an interesting example since it requires a cast, and routing the boolean input value depending on whether it's true (Pressed) or false (Released).

Such approach can be used for many other things, like jumping and activating abilities.

The framework provides more robust implementations not only for the Crouch Input Handler, but also for the Jump Input Handler, and multiple Ability Handlers.

Crouch Example
// Ninja Bear Studio Inc., all rights reserved. #pragma once #include "CoreMinimal.h" #include "NinjaInputHandler.h" #include "UInputHandler_CrouchSample.generated.h" UCLASS(meta = (DisplayName = "Sample: Crouch")) class PLUGINLABS_API UInputHandler_CrouchSample : public UNinjaInputHandler { GENERATED_BODY() public: UInputHandler_CrouchSample(); protected: virtual void HandleTriggeredEvent_Implementation(UNinjaInputManagerComponent* Manager, const FInputActionValue& Value, const UInputAction* InputAction, float ElapsedTime) const override;

// Ninja Bear Studio Inc., all rights reserved. #include "InputHandlers/InputHandler_CrouchSample.h" #include "InputAction.h" #include "Components/NinjaInputManagerComponent.h" #include "GameFramework/Pawn.h" #include "GameFramework/Character.h" UInputHandler_CrouchSample::UInputHandler_CrouchSample() { TriggerEvents.Add(ETriggerEvent::Triggered); } void UInputHandler_LookSample::HandleTriggeredEvent_Implementation(UNinjaInputManagerComponent* Manager, const FInputActionValue& Value, const UInputAction* InputAction, float ElapsedTime) const { ACharacter* OwningCharacter = Cast<ACharacter>(Manager->GetPawn()); const bool bShouldCrouch = Value.Get<bool>(); if (!IsValid(OwningCharacter)) { return; } if (bShouldCrouch && OwningCharacter->CanCrouch()) { OwningCharacter->Crouch(); } else if (!bShouldCrouch && OwningCharacter->bIsCrouched) { OwningCharacter->UnCrouch(); } }
Last modified: 25 October 2025