I have decided to move from Unity's old input system on to the New Input System
to control my mobile game.
I am having some issues with buttons, especially the a and b buttons. The A button represents the W key on the keyboard and the B button represents the Space key on the keyboard, while the joystick is implemented using the new input system using PlayerInput.actions[" "].readValue<TValue>()
, but for those two buttons I don't have any idea how to bind them to the keyboard. I have already added OnScreenButton
but when I play the game, the buttons not working.
private void Update()
{
this.thrusting = Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow);
if (m_MoveAction.ReadValue<Vector2>().x > 1 || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
{
this.turnDirection = 1.0f;
}
else if (m_MoveAction.ReadValue<Vector2>().x < -1 || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
{
this.turnDirection = -1.0f;
}
else
{
this.turnDirection = 0.0f;
}
if (Input.GetKeyDown(KeyCode.Space))
{
Shoot();
}
}
I have added
this.thrusting = Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow);
but why is it not working when I press the A button? What am I missing here?