Helicopter Game 3D, the Gem Update
Objectives
- Download Unity and get familiar with its interface.
- Read and understand all of the Helicopter Game 3D source code from Lecture 8.
- Add Gems to the game that spawn in much the same way as Coins, though more rarely so. Gems should be worth 5 coins when collected and despawn when off the left edge of the screen.
- Fix the bug whereby the scroll speed of planes, coins, and buildings doesn’t reset when the game is restarted via the space bar.
Getting Started
Download the distro code for your game from cdn.cs50.net/games/2020/fall/assignments/8/assignment8.zip and unzip assignment8.zip, which should yield a directory called assignment8.
Then, in a terminal window (located in /Applications/Utilities on Mac or by typing cmd in the Windows task bar), move to the directory where you extracted assignment8 (recall that the cd command can change your current directory), and run
cd assignment8
Downloading Blender
Make sure to download the correct (older!) version of Blender, not the latest version, per these instructions!
First, in order to be able to import some models into our scene appropriately (and to hopefully give you a taste of what 3D modeling is all about, should you be interested), head here to download version 2.79 of Blender, a free and open-source 3D modeling toolkit that rivals most commercial equivalents. (If not sure which file is right for your system, go ahead and download the newest version and check the filename of that file, then delete it and download the version 2.79 equivalent!) Using and mastering Blender is in and of itself a tremendous skill and art form and not required of this class, but do experiment if you feel so inclined! You can find some fantastic learning resources here and here! Should you wish to tinker with the models used in this project, you can find the helicopter, skyscrapers, and airplane (which I so crudely modeled) in the Assets/Resources/Models folder of the Unity project you’ve downloaded!
Downloading Unity
You will, of course, need to download Unity. To begin, download Unity Version 2018.4.28f1. The setup is very straightforward, but you will need a Unity ID in order to use the software (which is free!), so do visit this link to create one; you should also be prompted to create a new Unity ID via the software’s launcher once it’s downloaded onto your computer.
Your assignment must be developed and tested using Unity Version 2018.4.28f1. Computers that utilize an Apple Silicon chipset, such as an M2 or M3 processor, may have difficulty opening and running this version of Unity. If you cannot open this version of Unity on such a computer, consider installing Parallels and installing this Unity version within an instance of Windows 11.
Once you’ve downloaded and logged in to Unity, just click the “Open” button on the launcher and browse to the folder of the cloned code from the distro, and the project will open up!
But wait… nothing seems to load into the scene once you’ve opened it! With the project open in Unity, navigate to Assets/Resources/Scenes, and then select Main in the file browser at the bottom of the screen, double-clicking to open, and all should be loaded into the scene view!
Note: If you find that some of the models in your scene are not showing up, it’s likely because you either don’t have Blender installed yet (see instructions above), or you opened the project prior to the Blender installation. If you already have Blender installed and still don’t see anything, do just right-click, in the Unity editor, any of the models located in Assets/Resources/Models and select the Reimport All option, which should fix missing models after a few moments of loading! Further, if you have downloaded the incorrect version of Unity and opened the distro code using that incorrect version, you will need to re-download the distro code fresh to have it function correctly.
Next-Level
Unity is a lot to take in at once, but beneath all of the details, we’ll find that this set of tools will allow us to be our most flexible and productive yet, even when coding in C#! As such, this assignment is meant less to be intensive and more just to get a grasp on navigating Unity and understanding how things work.
Specification
- Add Gems to the game that spawn in much the same way as Coins, though more rarely so. Gems should be worth 5 coins when collected and despawn when off the left edge of the screen. We have all of the pieces for this already implemented in the
CoinandCoinSpawnerclasses, so it should suffice simply to make some new classes for theGemandGemSpawnerbehaviors! In the Proto resource pack included in theAssetsfolder, you’ll find a model for a gem you can use, but feel free to import your own! You’ll need to make a prefab, recall, that you can attach to theGemSpawnercomponent, should you choose to implement it similarly to what’s in the distro. There are of course other ways to implement this behavior, so feel free to experiment with the software as a chance to learn it all the more thoroughly if curious (but if you do decide to place it somewhere more unorthodox, make extremely sure when you commit your code that the staff is able to find it relatively quickly)! Do remember to makeGemsworth 5 coins instead of just 1, and ensure they’re more rare thanCoinsas well! Aside from that, they should behave identically toCoins, including moving automatically from right to left and despawning when past the left edge of the screen! - Fix the bug whereby the scroll speed of planes, coins, and buildings doesn’t reset when the game is restarted via the space bar. This one’s a one-liner; note that static variables aren’t actually reset upon loading a scene, so a place to check would be the
SkyscraperSpawner, as thespeedfield therein is what actually drives the speed forSkyscrapers,Airplanes, andCoins! However, we won’t find that this is the place where the game is reset upon pressing the space bar, and thus changingspeedhere doesn’t make much sense; any guesses as to where the code for resetting the game could be located?
Errata
NONE
How to Submit
Step 1 of 2
- Download the README.md template.
- Fill out all
TODOentries in the template as appropriate, and mark a self-assessment of your design score. Then, save yourREADME.mdfile. - Go to CSCI E-23a’s Gradescope page.
- Click Project 8: Helicopter.
- Drag and drop your downloaded
README.mdfile to the area that says “Drag & Drop”. - Click Upload.
Step 2 of 2
- Download a ZIP file of your
assignment8directory, containing your implementation of this project. - Upload your submission via our Dropbox file request for this project.
- Click Add files, then Files from your computer and select your previously downloaded file.
- Click Upload.
You should see a message that your file finished uploading and that we were notified of your uploaded files. Contact your teaching fellow if not!
Your submission is not considered complete until BOTH of the above steps are complete. Omitting either step is equivalent to not submitting the project at all.
Late-submitted work will be flagged in both the Dropbox file request and on Gradescope, and any late penalty assessed will be based on whichever of the two steps was completed the latest.