Programming My Life Rotating Header Image

Unity

Currently, my job is to create a game to teach astronomy to middle school students. Luckily for me, there is an abundance of options for game engines to help me ranging from the simple and free (Scratch and Alice) to the expensive and complex (Unreal, etc). For our project we wanted an engine deep enough to cover multiple game types in one game that was reasonably priced.  After debating over the 2D vs. 3D issue, I decided 3D might be too complex for the style of game we wanted to create.  However, after prototyping a few game ideas in several different engines, we settled on Unity for its flexibility and affordability (free for the indie version $1200 for the pro version).  Even though it is primarily a 3D engine, 2D games can be made without much trouble.

In order to get familiar with the Unity engine, I followed two tutorials I found in the Unity forums. The first was a basic shmup.

The second tutorial was a redux (in C#)  of the first plus an extension that included models for the ship and asteroid.  While I followed along with this tutorial, I decided to keep everything in JavaScript.  This helped me to clarify some of the elements of the Unity engine independent of language.

After completing the tutorials, I decided to extend the game a bit to include bombs, more asteroids and large asteroids.  As of this writing, I haven’t made final decisions for how to complete the game (whether it will be a score the player must or a set time limit), but the current version can be found here:

http://programmingmylife.com/spaceShooter/spaceShooter.html

Unity makes the process of uploading any game you build in the engine to a website incredibly easy.  When making a build of a game you simply have to use the following settings:

File >  Build settings > web player      (make sure to include all scenes)

When you build the game it will create a *.unity and a *.html file (the * represents the name of the game that you set).  Assuming your web host knows what to do with the .unity file, you can simply upload the two files and the game will run at that web location.  If, like me, your web host doesn’t support the .unity file format you will simply need to include in the directory with the .unity and .html file the following in a file called web.config:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>
    <system.webServer>

        <staticContent>
            <mimeMap fileExtension=".unity3d" mimeType="application/vnd.unity" />

     </staticContent>
    </system.webServer>

</configuration> 

I was able to find these instructions from this query at Unity Answers.  Unity Answers is a great service that runs in addition to the Unity forums.  These two complementary services along with the users give Unity a strong community that should allow users from novice to advanced to find answers to any problems they might have.

Leave a Reply