0

I am doing camera navigation (Movement/Rotation) on Update event in this way:

void UpdateMovement()
    {

        bool accelerate = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
        moveDirection   = 
            new
            Vector3(
                Input.GetAxisRaw("Horizontal") * moveSpeed, 
            0, 
            Input.GetAxisRaw("Vertical") * moveSpeed);
        //moveDirection = new Vector3(Input.GetAxis("Horizontal") * moveSpeed, 0, Input.GetAxis("Vertical") * moveSpeed);
        moveDirection   = transform.TransformDirection(moveDirection);

        if (Input.GetButton("Up"))
        {
            moveDirection.y += moveSpeed;
        }
        else if (Input.GetButton("Down"))
        {
            moveDirection.y -= moveSpeed;
        }

        if (Input.GetAxisRaw("Mouse ScrollWheel") > 0)
        {
            moveDirection.y = moveDirection.y + scrollSpeed;
        }
        else if (Input.GetAxisRaw("Mouse ScrollWheel") < 0)
        {
            moveDirection.y = moveDirection.y - scrollSpeed;
        }


       moveDirection *= (accelerate ? speed : moveSpeed);
        controller.Move(moveDirection * Time.deltaTime);

    }
    void UpdateRotation()
    {
        if (!Input.GetMouseButton(1))
            return;

        rotationX += Input.GetAxis("Mouse X") * lookSpeed;
        rotationY += Input.GetAxis("Mouse Y") * lookSpeed;
        rotationY = Mathf.Clamp(rotationY, -90, 90);
        rotationZ = Input.GetAxis("Mouse ScrollWheel");

        transform.localRotation = Quaternion.AngleAxis(rotationZ, Vector3.forward);
        transform.localRotation = Quaternion.AngleAxis(rotationX, Vector3.up);
        transform.localRotation *= Quaternion.AngleAxis(rotationY, Vector3.left);
    }

All working fine but the problem on WebGL canvas when I rotate the camera using mouse and comes out of the bound of WebGl canvas meanwhile, I also continuously press horizontal or vertical key, then release input key doesn't work. Remember I logged the key[Input.GetAxisRaw("Horizontal"),Input.GetAxisRaw("Vertical")] input and found that it is not reset to zero on release.

 Debug.Log("Hr GetAxisRaw : " + Input.GetAxisRaw("Horizontal"));
 Debug.Log("Vertical : "     + Input.GetAxisRaw("Vertical"));

Normally when I don't use camera rotation using mouse and during this time, when i release the horizontal/vertical key, it works fine. I was previously using Input.GetAxis now i am using Input.GetAxisRaw but the problem is same.

Keyboard input settings

9
  • I had issues with webgl and this, and found which unity claims made no sense,but I had 20 people who could repro it, that somehow webgl was spamming dns and that things like zone alarm and routers with dos prevention elements actually made it so input keys ran like sloths.. Once the game is in memory it shouldnt need to be doing any further checks but somehow it was.. GetAxis is kinda buffered, try the raw one..
    – BugFinder
    Jun 19 '19 at 13:30
  • If you look the code and question i have already done this. But still the same issue. I amazed that i didnt find any related issue on web. Can you share any link? Further it is not make sense that this issue is related to dns or internet Jun 19 '19 at 15:09
  • I didnt say yours was definitely like mine. Only that i had seen similar. You have multiple getaxis still in your code, rather than repeatedly calling it, why no keep the value
    – BugFinder
    Jun 19 '19 at 21:54
  • Oh right, there are still some GetAxis remaining, let me changed that too. I share the findings Jun 20 '19 at 4:29
  • I have replaced GetAxis, still the same issue. Jun 20 '19 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.