Horizontal input / GetAxisRaw not working in WebGL build

Hello.
I’ve finished my Project Boost from the 3D programing course & I’m trying to upload it to the web, but when it’s uploaded & I test it the Left/Right input is not registering & my rocket can do nothing but fly straight up.
This happens on both ShareMyGame & Itch.io.
Everything else works as it should so I wonder if there is any problem with the fact that I’ve used Input.GetAxisRaw(“Horizontal”); for my steering input or have I missed anything else?

Everything works in a standalone pc build & in editor.

My Code (if it’s relevant):
void Update()
{
if (pauseMenu != null) { CheckPause(); }
if (!gameIsPaused)
{
HandleInput();
if (lowerVolume) { LowerMusicVolume(); };
}
}

 private void HandleInput()
{
    if (allowInput)
    {
        ProcessThrust();
        if (!isGrounded) { ProcessRotation(); }
    }
    if (won) { AwaitInput(); }
}   

private void ProcessRotation()
{
    //float direction = Input.GetAxisRaw("Horizontal");
    float direction = (Input.GetAxisRaw("Horizontal") * PlayerPrefsController.GetCtrlInversion());
    if (direction != 0f)
    {
        Rotate(direction);
        if (allowAudio) 
        {
            allowAudio = false;
            StartCoroutine(PlayTurnAudio());
        }
        if (direction < 0f) 
        {
            lt = true;
            SetTurnAnimation(left:true); 
            SetSideThrusterVFX(left: true);
            if (rt) { SetSideThrusterVFX(right: false); rt = false; }
        }

        else if (direction > 0f) 
        {
            rt = true;
            SetTurnAnimation(right:true); 
            SetSideThrusterVFX(right: true);
            if (lt) { SetSideThrusterVFX(left: false); lt = false; }
        }
    }
    else 
    {
        SetTurnAnimation();
        SetSideThrusterVFX();
        lt = false; rt = false;
        leftThrusterLight.enabled = false;
        rightThrusterLight.enabled = false;
    }
}

Hi there, are you using the keyboard to play or are you trying to use a gamepad?

The game supports both keyboard & gamepad.
After a while I determined that the stering does work but sometimes it just refuses, no clue why.
And if it does refuse, if I open my options menu and manipulate the volume sliders left & right the steering starts working again… ¯_(ツ)_/¯

But I decided that is good enough for this project.

There are definetly some major issues with gamepads and webgl for several versions of Unity. I have yet to see a solution since it is related to how the browser sees the input and passes it to the webgl frame input. If you are only having this issue on gamepad, I’d say that’s the issue.

Else you can try grabbing the values of the keys directly instead of the using the GetAxisRaw, that should circumvent the issue. You can also try GetAxis instead of GetAxisRaw and see if that helps. There is also the new input system if you are up for something a little more flexible but a little more work.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms