Search Unity

How to update input system manually?

Discussion in 'Input System' started by PhilSA, Mar 6, 2019.

  1. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I am making an online game with its own custom fixed update (different from the one Physics uses by default) for the ticking of the networked "gameplay simulation", and I need player input events to only be processed at a specific point in that custom fixed update I made.

    for instance, if a player pressed Jump, I don't want that JumpPressed event to potentially be consumed by the regular Update, because I need it in my custom fixed update instead

    So far I have tried:
    • Setting "Update Mode" to "Process Events Manually" in the ProjectSettings window
    • in my fixed update loop, call
      Code (CSharp):
      1. UnityEngine.Experimental.Input.InputSystem.Update(InputUpdateType.Manual);
    But this does not seem to work. I don't get any input events, and I made sure the ".Update" really does get called by my code. Any ideas?
     
    Last edited: Mar 6, 2019
    deus0 likes this.
  2. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Also tried to use the InputActionTrace exactly like it is shown here: https://github.com/Unity-Technologi...emo/SimpleController_UsingActionEventQueue.cs

    ...but still no success

    Tested in 2018.3.5 and 2019.1b4

    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.Experimental.Input;
    6. using UnityEngine.Experimental.Input.Interactions;
    7.  
    8. public class InputTest : MonoBehaviour
    9. {
    10.     public MyControls MyControls;
    11.  
    12.     private InputActionTrace m_ActionTrace;
    13.  
    14.     private void OnEnable()
    15.     {
    16.         MyControls.Newactionmap.Enable();
    17.  
    18.         m_ActionTrace = new InputActionTrace(MyControls.Newactionmap);
    19.  
    20.         //MyControls.Newactionmap.Get().actionTriggered -= m_ActionTrace.RecordAction;
    21.         //MyControls.Newactionmap.Get().actionTriggered += m_ActionTrace.RecordAction;
    22.     }
    23.  
    24.     private void OnDisable()
    25.     {
    26.         MyControls.Newactionmap.Disable();
    27.     }
    28.  
    29.     // Update is called once per frame
    30.     void Update()
    31.     {
    32.         InputSystem.Update();
    33.  
    34.         Debug.Log(m_ActionTrace.count);
    35.         foreach (InputActionTrace.ActionEventPtr eventPtr in m_ActionTrace)
    36.         {
    37.             InputActionPhase phase = eventPtr.phase;
    38.             InputAction action = eventPtr.action;
    39.  
    40.             if(action == MyControls.Newactionmap.Test)
    41.             {
    42.                 IInputInteraction interaction = eventPtr.interaction;
    43.                 switch (phase)
    44.                 {
    45.                     case InputActionPhase.Performed:
    46.                         Debug.Log("TEST");
    47.                         break;
    48.  
    49.                     case InputActionPhase.Started:
    50.                         break;
    51.  
    52.                     case InputActionPhase.Cancelled:
    53.                         break;
    54.                 }
    55.             }
    56.         }
    57.  
    58.         m_ActionTrace.Clear();
    59.     }
    60. }
    61.  
     
    Last edited: Mar 6, 2019
  3. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Sorry for the lag here...

    That one is meant for the setup you describe and the steps and code you go through are expected to work. But the path has not seen much testing yet and looks like we still have some work to do there. I've filed a ticket here and QA will give it a go.
     
    deus0, dzamani and PhilSA like this.