'Unity On-screen Button doesn't seem to hold down on touch screens
I am using the New Input System and the unity On-screen button scripts provided in it.
My game has 4 buttons; Fire right, Fire left, Move left, Move right. I have mapped the buttons using the On-screen button scripts to O (to fire left), P (to fire right), left arrow, right arrow. which is what is used when you play on PC.
The mapped controls for movement and UI are the default ones with the New Input System.
These on-screen buttons work fine when in Unity editor. The fire buttons tap, and the move buttons can be held down.
When I play the game on mobile, the fire buttons work as expected, but the move buttons don't.
Sometimes the character may move for a under a second at the start of holding them down but don't work continuously as I'm holding down the button (as they do in the unity editor).
Can anyone suggest what is happening? or any other info needed?
void FixedUpdate()
{
Vector3 targetVelocity = new Vector2(horizontalMove * speed, m_Rigidbody2D.velocity.y);
m_Rigidbody2D.velocity = Vector3.SmoothDamp(m_Rigidbody2D.velocity, targetVelocity, ref m_Velocity, m_MovementSmoothing);
}
public void Move(InputAction.CallbackContext context)
{
horizontalMove = context.ReadValue<Vector2>().x;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
