Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question WoW Style Input Mapping

Discussion in 'Input System' started by IterativeKing, Mar 1, 2022.

  1. IterativeKing

    IterativeKing

    Joined:
    Apr 17, 2019
    Posts:
    5
    Hello,

    I am currently working on action bars for my RPG and I want the player to have the ability to simply hover over a slot(on the action bar) and press the inputs for that specific slot. For example, hover over spell on bar and input control + k. Control +k now activates the spell in that slot.

    So far my thoughts are creating new actions per instance the player does this. The main issue is how do I get which inputs were given, including composites (1/2 modifiers).
     
  2. IterativeKing

    IterativeKing

    Joined:
    Apr 17, 2019
    Posts:
    5
    I actually found a basic solution but I do not know if there is a better built-in way. You can use this to see the latest input and just use that to create bindings.


    Code (CSharp):
    1. if (!eventPtr.IsA<StateEvent>() && !eventPtr.IsA<DeltaStateEvent>())
    2.             return;
    3.  
    4.         var controls = device.allControls;
    5.         var buttonPressPoint = InputSystem.settings.defaultButtonPressPoint;
    6.         for (var i = 0; i < controls.Count; ++i)
    7.         {
    8.             var control = controls[i] as ButtonControl;
    9.             if (control == null || control.synthetic || control.noisy)
    10.                 continue;
    11.             if (control.ReadValueFromEvent(eventPtr, out var value) && value >= buttonPressPoint)
    12.             {
    13.                 if(!control.path.Contains("mouse"))
    14.                 {
    15.                     Debug.Log(control.path);
    16.                 }
    17.             }
    18.         }