Unity Tutorial – Web Player Failed To Download Data File

unity logo

Up until now in my limited game design “career” I have for the most part been doodling around with UDK. I did use Blender’s Game Engine to create a few game-thingies a couple of years ago (of which one can be seen here). Back then I also downloaded Unity for the first time and took a quick look at it. However, since it’s based a lot on coding it just seemed like a too big thing to dive into.

But now I’m getting a somewhat tired of UDK, and I prefer using Blender for modeling the stuff I use in the games, and not using it’s game engine anymore – don’t get me wrong, I truly do believe Blender’s game engine is more than usable, but for me there exists more interesting engines out there. Therefore, I have now picked up Unity again, this time the newest version, Unity 4.3, which seems pretty damn awesome.

Anyway, I started with the beginner tutorials on Unity’s pages, and completed the first game creation tutorial – you know, the one where you create a ball that collects rotating boxes. At the end of the tutorial series the guy exported the game to be played in the browser, and in about two seconds put it up on his own website ready to go right out of the box. Having a few different sites I wanted to check if it really was that easy, and so I opened the FileZilla FTP client, created a “games” folder within the second site on that specific hosting package, dragged the game files over and opened the page in the browser, almost drooling with excitement to see the beautifully easy way to get my game up on the web. And just as I was about to explode with joy, instead of the game loading, this message showed up:

unity web player error message

FAILED TO DOWNLOAD DATA FILE

I almost burst out laughing, because it surely couldn’t just be that easy after all, now could it? Of course not.

So I started checking the most basic things I could think of first:

1) Deleting the file from the server and re-uploading.

– Didn’t help.

2) Tried instead to upload it directly to the root folder, you know, just in case.

– Didn’t help.

3) Figured it didn’t matter, so I uploaded it back into the games folder. I’m using the Comodo Dragon browser, which is pretty strict when it comes to what it allows and not, so I thought maybe it was the problem. Tried loading the page in FireFox.

– Didn’t help.

Tried Chrome.

– Didn’t help.

Tried Explorer.

– Didn’t help.

4) Ah, maybe it was the cache that needed to be deleted. Tried it.

– Didn’t help.

5) Started searching around the web for others that might’ve experienced the same thing. Turns out it’s not an uncommon problem at all. There were a bunch of good suggestions laying around, but, after trying more different things, plus ignoring some I knew wouldn’t work, I found someone somewhere – I’m sorry, don’t remember where – that suggested creating a .txt file and writing this in it:

<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=”.unity3d” mimeType=”TYPE/SUBTYPE” />
</staticContent>
</system.webServer>
</configuration>

Once the .txt file contains this code, rename the file to web.config. Then put this file in your root folder, and voila! the problem will be fixed. I tried this – being careful to make a backup copy of the web.config file that was already residing there – and it worked. The game loaded perfectly.

However, if the story ended with that, I wouldn’t have created this particular “tutorial”. This one exists because of what I now experienced:

Okay, so the web player worked, but now that the previous web.config file was substituted with this new one, wouldn’t that mean some information some of my other sites need would be gone? Did my other sites still function properly?

Well, I opened one of them, and sure enough, the homepage opened just fine. But when I tried clicking some of the links pointing to other places on the site, I got a new error message. No matter which link I clicked, the page died. So changing the web.config file was a bad idea.

I won’t drag this story out any longer:

THE SOLUTION

The ultimate solution that fixed everything without f*cking up for any of the other websites sharing the same root, was to open the pre-existing web.config file in the root folder, and inserting this line:

<mimeMap fileExtension=”.unity3d” mimeType=”TYPE/SUBTYPE” />

in between <staticContent> and </staticContent>

Here’s a snippet from the web.config file now:

<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration>
<system.webServer>

<staticContent>
<clientCache cacheControlMaxAge=”14.00:00:00″ cacheControlMode=”UseMaxAge”/>

<mimeMap fileExtension=”.unity3d” mimeType=”TYPE/SUBTYPE” />

</staticContent>
<urlCompression doDynamicCompression=”true” dynamicCompressionBeforeCache=”true”/>
<caching>
<profiles>
<add extension=”.jpg” policy=”CacheForTimePeriod” duration=”00:01:00″ varyByHeaders=”Accept-Language”/>

…etc. etc.

So, in other words, include that specific line in that specific place in the web.config file and you’ll be good. At least if it’s the same thing causing your problem as caused my problem.

After fixing this, everything loaded perfectly:

unity browser game working

Click here to check out and try the working version on the site, or, if you’re interested enough, check out an early version of “Art of Rolling”, which has the same game dynamics as the test above, but is a level where you have to grab all the boxes, by clicking HERE

Art of Rolling screenshot

[Update, 01.12.14]

However, if you still don’t understand what to do, I created a new post with a video showing exactly where you can locate you website’s root folder + where to insert the line of code. The new post lives HERE

 




13 Replies to “Unity Tutorial – Web Player Failed To Download Data File”

  1. Hello,

    I would like to ask what exactly a root folder is and where mine is. I have searched on the internet and it seems my root folder is in drive C:, most likely the “Windows” folder. While inside this folder, I searched for “web.config” and it came up with many .config files with the same name, web. There were also other .config files like web.config.default, web.config.comments, etc. I have looked in all the “web.config” files (not the other ones with similar names) and none of them have the line (I used Ctrl+F).

    My situation is the error “failed to download data file” occuring when I try to play a game, Attack on Titan Tribute Game. This can be found at fenglee.com/game/aog. It may be slightly different from yours, but it is quite similar.

    Any ideas?

    Regards

    • Greetings Fatah,

      Generally, a “root folder” is the folder containing all the files in a certain folder hierarchy. A corny analogy: If you have a big bucket containing smaller buckets, then the big bucket is the root folder, haha.

      The root folder I’m referring to in this specific case is the root folder that your website is living in, not where windows is on your hard drive. Thus, if I’m not mistaking and your problem is the same as the one I experienced, you then need to locate fenglee.com’s root folder and find the web.config file there. In my case, since I host that specific website (fungazm.com) on godaddy, I had to open my godaddy account and find the root folder where fungazm is stored.

      When/if you do find the correct web.config file, remember to make a copy of the original one before including the code I’ve provided in the solution – just in case the changes you make damage your website in any way. Always, always create backups!

      Try this and let me know what happens 🙂

  2. Um all im trying to do is play a game and everything you guys are talkign about makes no sense to me. Unity has fucked me over again

    • Hey dakota,

      are you trying to play a game you’re hosting on your own website, or just a unity game already put up by someone else on a website somewhere?

  3. Hello,

    I want to thank you very much for this post. Despite the fact that it has been published two years ago, it helped me a lot, saved me to be honest!

    Thanks for the effort making the tutorial!

    🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

*

nineteen − twelve =