- Home /
New Input System GetButton() Alternative
In the new Input System, is there a way to check if an Input Action is being performed?
Answer by obsidianz · Nov 09, 2020 at 09:48 PM
I've found that if I do this controlScheme.Player.MyAction.activeControl
it returns null if the action is not performimg.
Answer by rh_galaxy · Nov 09, 2020 at 06:48 PM
There are other ways, but the simplest get button state of a gamepad is like this:
using UnityEngine.InputSystem;
Gamepad gamepad = Gamepad.current;
if (gamepad != null)
{
if (gamepad.buttonSouth.isPressed)
{
Debug.Log("Button down");
}
if (gamepad.rightTrigger.ReadValue() > 0.5f)
{
Debug.Log("Trigger down");
}
}
If I have multiple key bindings in one Action it's annoying having do that for every single key. Also, If I decide to change one binding to a different key I would have to change it in the code.
I was wondering if there was a way to check if the Action itself was peing performed.
Your answer
Follow this Question
Related Questions
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
Speed pickup 1 Answer
Input System binding with one modifier composite value problem 1 Answer
[SOLVED] Input.GetAxis("Horizontal") returns wrong value? -1 Answers
How to make floating mobile keyboard in mobile game ? 0 Answers