Hardware Setup
- Follow the instructions to build the Teensy 3.1 Accelerometer. This will be used as the game controller through a USB serial connection.
- Note: the Unity game expects the Accelerometer's x, y, and z axis' to be oriented with the Y-axis arrow pointing to the right of the user and the X-axis arrow pointing toward the user when the circuit is in use.
Software Setup
- Download and install the Unity game development suite. (this takes a while, it's a big download)
Now lets take a get the Unity project working.
Step 1 - Download the Unity Plane Game project.
- Download the UnityPlaneGame.zip file and extract it to a UnityPlaneGame directory.
- Create an Assets directory under the UnityPlaneGame directory that was just created on your local drive.
- Download everything in the UnityPlaneGame/Assets directory of the repository and to your Assets directory.
- Extract the .7z compressed files to sub directories of the Assets directory that match the compressed file names. You will need 7-zip to extract the files. You can download 7-zip here.
- Copy the scripts directory and other files directly to the root of your Assets directory. Your Assets directory file structure should look as shown below.
Step 2 - Open the Unity Project.
- Open the Unity Game development suite.
- From the "File" menu, select "Open Project", then choose "Open Other" at the bottom left corner and browse to the UnityPlaneGame directory. Then click the "Open" button.
- The project should open and look something like the image below.
- Now Choose "Build and Run" from the "File" Menu to make sure the project will build. If not, verify the above steps.
Step 3 - Change the COM port to match your Teensy 3.1 Accelerometer
- From the Project window in Unity, navigate to the scripts directory and open the PlaneAnimator.cs script by double clicking on the file. The file will open with MonoDevelop.
- In the script, change the COMPORT string from "COM6" to the COM port that your Teensy 3.1 Accelerometer is on and Save your changes.
Step 4 - Run the Game
- At this point, make sure your Teensy Accelerometer is plugged in. (The USB cable). The game is programmed to open the serial port only once on start up, so it will not work if you plug it in after the game is already running.
- Return the the Unity project window.
- From the File menu, select Build and Run. A window will open with the Unity logo in it, and then the game scene will appear with the plane visible on the screen. Try using the Teensy accelerometer to control the plane. Tilting the accelerometer left and right should make the plane move left and right. Also try tilting it back with the front side higher than the backside. That should make the plane climb on the screen. Tilt it in the opposite direction to make the plane dive. See if you can find the buildings and fly through them! There are no collisions in the game so you can fly through anything!