WebGL build behavior different than in editor.

I am working through projects and missions on Unity Learn. The current project I’m working is “The Floor Is Lava.” I’ve created a vertical obstacle course consisting of 4 platforms with primitives placed on each platform for the sphere to collide with. In Editor and Game mode, everything works great. All objects have rigid bodies, colliders, and some have physics material applied to allow the sphere to bounce off on collision and fall to the next lower platform.

When I publish a WebGL build to Unity Play, the sphere bounces at slightly different angles than in Editor and Game mode, causing it fall off the third platform. Has anyone else encountered anything like this?

1 Like

This can occur due to extreme delta time deviation. Specifically on WebGL it is commonly seen that the first couple frames render terribly slowly due to single-threaded asset loading, thus there’s a high delta time, and with that comes deviations in physics behaviour. You may be able to observe the same behaviour in playmode if you have a script that sets Application.targetFramerate to a low value, like 1-10.

One way to fix that is to have a loading scene, or pause affected scripts for the first couple frames, in order to have all initial processing (typically asset load) be done before the gameplay begins.

1 Like

Thank you. I’m going to give your suggestions a try.