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.
  2. Dismiss Notice

Unity Input System 1.0.0

Discussion in 'Input System' started by TeamDefiant, May 8, 2020.

  1. TeamDefiant

    TeamDefiant

    Joined:
    Mar 29, 2017
    Posts:
    50
    Hello, I'm having trouble with the new input system.
    It works fine in editor, but not when I do an x86_64 build, what am I doing wrong?

    (Forgot to say, i'm currently using a wired xbox one controller.)

    This is basically the code i'm using:
    Code (CSharp):
    1. using UnityEngine.InputSystem;
    2.  
    3.  
    4. public class InputManager : MonoBehaviour
    5. {
    6.     public Gamepad gamePad = Gamepad.current;
    7.     public Vector2 move = new Vector2();
    8.     public Vector2 rotate = new Vector2();
    9.  
    10.     void Update()
    11.     {
    12.  
    13.         bool crouch = gamePad.buttonEast.isPressed;
    14.         bool interactPrimary = ( gamePad.leftTrigger.ReadValue() >= 0.5 );
    15.         bool interactSecondary = (gamePad.rightTrigger.ReadValue() >= 0.5);
    16.  
    17.         move = gamePad.leftStick.ReadValue();
    18.         rotate = gamePad.rightStick.ReadValue();
    19.     }
    20. }
    And here's a snip of my unity settings.
    UnityinputSystem.jpg
     
  2. TeamDefiant

    TeamDefiant

    Joined:
    Mar 29, 2017
    Posts:
    50
    No one? Nothing? Not even a nudge in the right direction?
     
  3. zuk0

    zuk0

    Joined:
    Jul 15, 2014
    Posts:
    2
    I'm new with the Input System too, but have you tried looking at your debug logs to confirm if your trigger events are being registered?
     
  4. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Move this to OnEnable or Start. The initializer will run as part of the constructor and, with this being a serialized object, will thus run during loading. This works in the editor as the input system will have been started as part of the editor but won't work in the player as the system is still starting up. So you get null here.
     
    elZach and TeamDefiant like this.
  5. TeamDefiant

    TeamDefiant

    Joined:
    Mar 29, 2017
    Posts:
    50
    Move this to OnEnable or Start. 

    Such a simple answer, such a stupid mistake to make.

    Many thanks, that's solved it.