Search Unity

Get name instead of value

Discussion in 'Input System' started by gareth_untether, Nov 16, 2020.

  1. gareth_untether

    gareth_untether

    Joined:
    Jan 5, 2018
    Posts:
    69
    How do I get "Up" ie. the name instead of the vector2 value?

    I'm using ctx.ReadValue<Vector2>() to get the vector2, but I just want to know if it's up/down, rather than the actual value.

    Code (CSharp):
    1. myAction.AddCompositeBinding("2DVector") // Or "Dpad"
    2.     .With("Up", "<Keyboard>/w")
    3.     .With("Down", "<Keyboard>/s")
    4.     .With("Left", "<Keyboard>/a")
    5.     .With("Right", "<Keyboard>/d");