Diary 2: Web builds for indie games
A little warning, this diary entry will get a little technical :)
One of the reasons I’m using Unity3d to build my game is that it makes it really easy to build to different targets. Unity supports windows, mac, Linux, most of the consoles, and last but not least web players.
The fact that a full on game can be run in a modern web browser is quite amazing. While I intend for the final release of the game to be stand alone, it’s very helpful to be able to publish web builds as it gives people an easy way to try out your game.
Unity Plugin vs WebGL
Right now Unity has two different approaches to building for web players. The first is the Unity Plugin. This has been around for ages. It’s great. It’s small, fast, and works on most things. It however has one major drawback. It’s no longer supported on Chrome and may be dropped from other web browsers in the future too.
This is because the Unity Web player uses an old native plugin API NPAPI (from Netscape all those years ago). The NPAPI gives a plugin nearly full control of the systems resources, which is great for performance, but terrible for security. Google and others are taking steps to phase out this 22 year old API in order to clean up their browsers and remove potential security risks.
Ok… so here is where it gets technical.
Let’s look at the pros and cons of doing this.
- You end up with a game that should run almost anywhere.
- The user doesn’t need to install anything to run your game.
- Having such a lengthy build chain means slow compile times.
Impact on Endurance
Because the Alpha builds of Endurance are built with the Web player plugin, some people are not able to run it. I spent most of today testing Endurance with the new WebGL to get a feel for how it would work. Here is what I found.
With most of the debugging disabled I get about 1/7th the speed using WebGL as I do running natively. Even so, I still hit 60fps in the dungeon on my development machine.
This is the real killer. The WebGL version of the game weighs in at 205Mb! This compares to the Web player plugin version which is just 35megs.
Unity will soon support compressing their WebGL applications which will bring the size down to around 100Mb for me, and potentially more like 70Mb once I remove some of the debugging information.
When doing my testing I noticed the lighting in the WebGL build is quite different from that in the other builds. See below.
I spent quite a bit of time trying to work out what is happening here. All I can gather is that in the WebGL build all my materials change their smoothness property from what I have it set to, to a default (very high) value.
The great thing about Unity is being able to push your game out to another platform with just the click of a few buttons. The WebGL platform is still a work in progress, but as it stands today an almost 6x increase in size, 7x speed drop, and slightly broken lighting means I’ll have to wait a little longer before I make the switch.
That being said. The WebGL platform is getting better and better, and I’m very glad it’s there, but for now it’s the Unity Plugin for me.
Today’s Changes [0.11.6]
- Tested the WebGL platform.
- Fixed some issues with lighting and doors.
- Stopped “new record” notifications when creating new characters.
- You can now use the arrow keys to move (as well as WASD)
- Various bug fixes and tweaks.
Endurance now sits on a few sights, mine, IndieDB, and itch.io.
Most of these I’ll just be updating for major releases, however the most up-to-date version can always be previewed from my website here