Search Unity

How to integrate the new input system into bolt?

Discussion in 'Input System' started by arthurvasconcelos, Jul 30, 2020.

  1. arthurvasconcelos

    arthurvasconcelos

    Joined:
    Dec 9, 2016
    Posts:
    4
    Hi, I am trying to integrate the generated class from my input resource into Bolt adding the generated types into Bolt units but it didn't work all the way through...

    Anyone have had done this or had an idead on how to do it?
     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,079
  3. arthurvasconcelos

    arthurvasconcelos

    Joined:
    Dec 9, 2016
    Posts:
    4
    In his last two updates before quitting open source, he removed input system types and units https://github.com/LifeandStyleMedia/BoltExtensions/releases/tag/1_3_1 and the previous one he warned to not use it due to being unstable and buggy https://github.com/LifeandStyleMedia/BoltExtensions/releases/tag/1_3_0.

    :(
     
  4. arthurvasconcelos

    arthurvasconcelos

    Joined:
    Dec 9, 2016
    Posts:
    4
    Well the way that I found to use it, it to have a script that will write the values to a scriptable object and then Bolt consumes from that scriptable object...
     
  5. gvidov

    gvidov

    Joined:
    Aug 4, 2017
    Posts:
    3
    A bit confused about this. Is it now not possible to use new input system with Bolt, or you can use the return event nodes?
    Is it possible to provide a sample, please?

    edit: never mind i found out that you can use custom event nodes and CustomEvent.trigger() in code to link the unity input events and bolt
     
    Last edited: Aug 12, 2020
  6. rebl_

    rebl_

    Joined:
    Jun 24, 2019
    Posts:
    7
    @gvidov do you have any reference/tutorial for that?

    What about Bolt 2? Will the new Input System be fully supported?
     
  7. gvidov

    gvidov

    Joined:
    Aug 4, 2017
    Posts:
    3
    I haven't yet gotten the chance to try Bolt 2, but from what i read at the time, they plan to implement the input system.

    Here's how i did it.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.InputSystem;
    3. using Bolt;
    4.  
    5. public class InputEvents : MonoBehaviour
    6. {
    7.     private Controls controls;
    8.     private InputAction moveAction;
    9.  
    10.     void Awake()
    11.     {
    12.         if (controls == null)
    13.         {
    14.             controls = new Controls();
    15.         }
    16.         controls.Enable();
    17.         moveAction = controls.PlayerActions.Move;
    18.         controls.PlayerActions.Jump.performed += Jump_performed;
    19.         controls.PlayerActions.Jump.canceled += Jump_canceled;
    20.         moveAction.performed += ctx => Move_performed(ctx.ReadValue<Vector2>());
    21.         moveAction.canceled += ctx => Move_canceled(ctx.ReadValue<Vector2>());
    22.     }
    23.  
    24.     private void Jump_performed(InputAction.CallbackContext obj)
    25.     {
    26.         CustomEvent.Trigger(this.gameObject, "onJump");
    27.     }
    28.     private void Jump_canceled(InputAction.CallbackContext obj)
    29.     {
    30.         CustomEvent.Trigger(this.gameObject, "onJumpCancel");
    31.     }
    32.  
    33.     private void Move_performed(Vector2 direction)
    34.     {
    35.         CustomEvent.Trigger(this.gameObject, "onDirInput", direction);
    36.     }
    37.     private void Move_canceled(Vector2 direction)
    38.     {
    39.         CustomEvent.Trigger(this.gameObject, "onDirInputCancel", direction);
    40.     }


    You can pass arguments like for directional input
    custom event dir input.png Transition in State Graph
    custom event state transition.png Here's the State Graph Tree
    state graph with custom events.png
     
    HuaQiao likes this.
  8. Yaos

    Yaos

    Joined:
    Mar 26, 2015
    Posts:
    6
    Hello. I'm a C# newcomer and I've been trying to do what you did to link the new input feature to Bolt for a while. My script is not compiling correctly, and I believe it is because of the names of my files. Can you clarify what files are you calling in this script and which ones I should change ?



    here are my errors. Maybe it's something else.
     
  9. gvidov

    gvidov

    Joined:
    Aug 4, 2017
    Posts:
    3
    Sorry for the late reply and i hope this is still relevant. I think in your case the problem is the reference to Controls script. for me the Controls script is the Unity input systems generated c# class name for the Input Action Asset
    input_actions_controls.png