Search Unity

Can not ReadValue from a "Press Only" action?

Discussion in 'Input System' started by TheGamerX20, Oct 19, 2019.

  1. TheGamerX20

    TheGamerX20

    Joined:
    Dec 12, 2016
    Posts:
    8
    Hi!
    I've just started using the new Input System, and personally I prefer using code directly for Characters rather than events.. and also use Events for simpler tasks, so I'm reading input like this currently:

    Vector2 move = playerInput.actions["Move"].ReadValue<Vector2>();
    bool jump = playerInput.actions["Jump"].triggered;


    which works extremely well.. however I can not ReadValue from the "Press Only" actions..
    is there anyway to ReadValue from them or is this a bug?

    Vector2 pMove = playerInput.actions["PressMove"].ReadValue<Vector2>();

    the code above just yields a Vector2 with (0f, 0f), why is that?

    a part of my game needs a movement to be performed only once, even if the button is being held, how would I go about doing that? is there something other than ReadValue that I can't seem to find or is this a bug or?
    Thanks!

    EDIT: I should add that
    playerInput.actions["PressMove"].triggered;
    actually works just fine.. but I need the value.
     
  2. Yecats

    Yecats

    Joined:
    Jul 13, 2014
    Posts:
    69
    Without seeing your actual action / input binding setup, I'm just taking a wild guess here - is your action for pMove a button? If so, I believe you're looking to read out a float - 0 is off 1 is on.
     
  3. TheGamerX20

    TheGamerX20

    Joined:
    Dec 12, 2016
    Posts:
    8
    Hi, it's a Vector2 I made sure of it..
    I did find that I could just do this instead and it works:
    if(playerInput.actions["Move"].triggered && playerInput.actions["Move"].ReadValue<Vector2>().x > 0f)


    However I can't get this new Input System to work on iOS.. it just keeps giving me an error about Touchscreen pressure? I'm almost sure this is 3D Touch as I'm testing it on an iPhone 6S+, but it gives me the same error on an iPhone 6+.. the error only happens if I have a script that utilizes the new Input System and I use any On-Screen controls.

    I'll submit that to another thread as well maybe but posting it here in case I can get some help(file attached) :D
     

    Attached Files:

  4. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    @TheGamerX20 That very much looks like a bug. Would you mind filing a bug report through the Unity bug reporter? Would like to take a look.
     
    TheGamerX20 likes this.
  5. TheGamerX20

    TheGamerX20

    Joined:
    Dec 12, 2016
    Posts:
    8
    Hi! Which bug would you want me to report? the iOS one or can't ReadValue from "Press Only" Actions?
    honestly I left the new Input System cause of the iOS issue.. I hope someone can help me with that.
     
    GAURAVJPLAYZ likes this.
  6. GAURAVJPLAYZ

    GAURAVJPLAYZ

    Joined:
    Jan 19, 2021
    Posts:
    2
    So i was developing a multiplayer game for Android
    I want to send the input of a virtual joystick to my server side codes

    WILL THIS CODE WORK?




    private AndroidInput Pi;

    private void Awake()
    {
    Pi = new AndroidInput();
    }

    bool[] _inputs = new bool[]
    {
    Pi.control.Move.ReadValue<Vector2>().x > 0f,
    }
     
  7. protanker25

    protanker25

    Joined:
    Aug 7, 2021
    Posts:
    2
    Pi.Enable()