Joystick Axis not recognized when deployed to WebGL
Hello, I am currently trying to set up a controller with my WebGL Unity Game to make an object move left and right. The controller is an iNNEXT SNES USB controller. I have mapped the Horizontal D-Pad controls to:
Type: Joystick Axis
Axis: 4th axis (Joysticks)
Joy Num: Get Motion from all Joysticks
The controls work in the Unity Editor. When using the D-Pad, the player moves left and right. However, once I build the game for WebGL the Joystick controls are no longer recognized and the object no longer moves left or right. I also tried adding print statement for "Input.GetAxis("Horizontal")" and I receive -1 or 1 while testing in Unity, but when I build the game for WebGL, it stays on 0.
The code is:
void Update () {
if (Input.GetAxis("HorizontalDPAD") > 0){
MoveRight();
}else if(Input.GetAxis("HorizontalDPAD") < 0){
MoveLeft();
}
}
public void MoveLeft(){
transform.position += Vector3.left * movementSpeed * Time.deltaTime;
}
public void MoveRight(){
transform.position += Vector3.right * movementSpeed * Time.deltaTime;
}
Everything works in the Unity Editor, however, when I build the game for WebGL, the D-Pad is no longer recognized. Please let me know if you have any solutions or ideas on how to fix this. Thanks!
Answer by dongrout · Apr 15, 2020 at 09:00 PM
Did you find a solution? I'm finding that in the Unity Editor it's detecting joystick 1 & joystick 2 but then in WebGL it's detecting joystick 2 & joystick 3. I'm guessing that I'll have to setup 3 players in the Input Manager and switch player input depending on if it's a WebGL build or not.
Your answer
Follow this Question
Related Questions
input.getaxis not working with gamepad 0 Answers
Joystick Angle Problem 0 Answers
Unity New Input System stops working when activating Steamworks.net 2 Answers
Xbox joystick axis output at 1 when stick is at 75% 1 Answer
bluetooth AR gun with android 0 Answers