- Home /
New input system - How do I access Up/Down/Left/Right?
I'm trying to implement simple controls with the new input system but I cannot figure out how to access a certain property in the event object. Picture of my bindings:
I successfully make my player jump like so after subscribing to the jump event:
private void Jump_performed(InputAction.CallbackContext obj)
{
Debug.Log("Jumped");
rigidBody.velocity = new Vector2(0, 5);
}
However, I can't figure out how to access Up/Down/Left/Right as seen in my bindings above. Everything I'm finding prints W/A/S/D instead. Example:
private void Move_performed(InputAction.CallbackContext obj)
{
//Prints W, A, S ,D
Debug.Log(obj.control.displayName.ToString());
//Displays Move...
Debug.Log(obj.action.name.ToString());
//Displays PlayerControls...
Debug.Log(obj.action.actionMap.name.ToString());
}
I looked at the reference and couldn't figure it out either even though synthetic controls seemed similar near the bottom: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Controls.html
Ideally I'll be moving my character up/down/left/right depending on what is being pressed. I don't want to reference W/A/S/D like I currently have.
Edit: I found this and still don't know how to check what the composite binding is on event: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/ActionBindings.html#composite-bindings
Answer by fgbg · Jun 01, 2020 at 06:36 PM
For anyone wondering, it doesn't seem possible to access the Up/Down/Left/Right labels today. Why they exist? I don't know.
Your answer
Follow this Question
Related Questions
Why does the keyboard control what button is selected? 2 Answers
How to add controls? (WASD) 1 Answer
Unpausing with the new InputSystem 1 Answer