Skip to content

Plugin Example

Overview

This example is focused to produce this result:

  • When the Input Device is Keyboard Mouse Keyboard Mouse Input Device


  • When the Input Device is switched to Gamepad in runtime Gamepad Input Device


Input Keys Data


Input Action Keys Image - Plugin Settings

  • To setup some Plugin Default Values for the Project for this example;

    Edit >> Project Settings >> Plugins >> Input Action Keys Image

    Setting Value Description
    Supports Gamepad true Enables gamepad input for the project
    Change All Input keys Data to Default true A single Input Keys Data will be used
    Default Input Keys Data Created Instance Instance created in step 1

    Input Action Keys Image Plugin


Input Action Key Image

  • After creating the Input Keys Data, Now we can create a User WidgetBlueprint. For example, here I will name it WBP_InputActionKeyImageExample


  • After opening the WBP_InputActionKeyImageExample blueprint window, First add the Canvas Panel and then add the widget Input Action Key Image to the user widget.

    Create Input Action Key Image


  • For this example, Setting the following values:

    Setting Value Description
    Anchors Middle of the screen with both alignment and position We want our image to be at the center
    Size to Content true For making the size of the widget according to the texture
    Input Action IA_Interact I want this image to be shown on the interactable objects
    Input Mapping Context IMC_Default Since, the IA_Interact is defined in the IMC_Default
    Input Keys Data Set to Default Input Keys by default Input Keys Data are stored in the given Input Keys Data instance created recently
    Selected Input Key Texture Index 0 for both Keyboard Mouse and Gamepad Select Input Device to Gamepad to change the index for Gamepad. Here using 0 because we have only one key mapped for each Keyboard Mouse and Gamepad
    Is Selected Input Device Only false Since, this Input Action Key Image is gonna use both input devices i.e. Keyboard Mouse and Gamepad
    • When Input Device selected to Keyboard Mouse Keyboard Input Action Key Image Properties Keyboard Input Action Key Image View


    • When Input Device selected to Gamepad Gamepad Input Action Key Image Properties Gamepad Input Action Key Image Properties


Widget Switched On Input Device Changed

  • Now for showing the Move hint where the Keyboard Mouse has 4 different keys WASD and Gamepad has only one key Left Joystick, we are gonna use Widget Switched on Input Device. So, to use the Widget Switched on Input Device, we will create a new User Widget Blueprint named WBP_WidgetSwitchedOnInputDeviceChangedExample.


  • After opening WBP_WidgetSwitchedOnInputDeviceChangedExample, Add the followings in the respective order:

    Widget Switched on Input Device Changed Hierarchy



Results

  • After integrating the WBP_InputActionKeyImageExample to a interatable object and the WBP_WidgetSwitchedOnInputDeviceChangedExample to the player screen, We can get the result:

    • When the Input Device is Keyboard Mouse Keyboard Mouse Input Device

    • When the Input Device is switched to Gamepad in runtime Gamepad Input Device