WebGL Build Debugging

Part 1 various attempts

Tristan Engel
4 min readOct 17, 2021

In these articles we will review some issues we encounter when finishing up our work on this project.

We will mention various things we tried to identify the problem. These methods can be used for finding other issues as well.

WebGL Build 2017

In our case the PC build was working fine. The WebGL version however was game breaking issues.

When reaching a certain places in the game we couldn’t click and move for unknown reasons. This only happened in the WebGL build.

Check Colliders

For starters we searched for any colliders that could be blocking our raycast and prevent us from moving.

In the Hierarchy we can search all colliders by typing:

t:Collider

Check Camera Position

Since one camera was very close to another game object we disabled it to see it had any impact.

Multiple Camera’s

Another possible cause of weird behavior can be caused if you have multiple main camera’s. Just search in the hierarchy to check.

Multiple UI Canvas

In our various cutscenes we use the canvas for the fade in and out effects. We disabled all those game objects, since a canvas could be blocking our mouse clicks some way.

Occlusion Culling

This setting on the Main Camera turns off things that are not displayed to save performance. By disabling we make sure this isn’t causing our problem.

Update Nav Mesh

We noticed there was a small gap on our staircase that could cause possible issues. By increasing the step height in our Navigation Panel and baking again we made sure it was a continous nav mesh.

Nav Mesh gap
Navigation > Step Height increased

Raycast Debugging

To make it visible what is happening we updated our raycast script to create a cube. The bold part is for the cube. At the start of the script we created a handle to assign a cubePrefab from the Inspector.

RaycastHit hitInfo;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hitInfo))
{
_agent.destination = hitInfo.point;
GameObject cube = Instantiate(_cube, hitInfo.point, Quaternion.identity);
Destroy(cube, 3f);

}

Raycast Layer

We didn’t use layers for our raycast. So when clicking on objects like camera triggers or guards the first thing the raycast would return was a point above our nav mesh. To only return points on the nav mesh we made some changes.

  1. We created a new layer called “Floor” and set our floorcollider layer to it.
    Of other objects we all set the layer to “Ignore Raycast”.

2. Updated script raycast for player movement. The bold parts are new.

LayerMask mask = LayerMask.GetMask(“Floor”);
RaycastHit hitInfo;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hitInfo,float.PositiveInfinity, mask))
{
_agent.destination = hitInfo.point;
}

Since we made the raycast hit point visible with the cube we could see the cube not spawn on colliders or guard etc anymore. Sadly the issues still persisted.

--

--

Tristan Engel

Aspiring developer that’s self-learning Unity & C# to transition to a career with Unity. I got a passion for creating interactive experiences.