Goals for this homework

  • Set up Unity
  • Familiarize yourself with the Unity UI
  • Understand how objects interact in a game

You are expected to complete this assignment individually. If you need help, you are invited to come to office hours and/or ask questions on Ed. Clarification questions about the assignments may be asked publicly. Once you have specific bugs related to your code, make the posts private.

Another note about Ed. Ed is your community resource - please use those as discussions amongst yourselves. We are not monitoring it all day, rather we each have check-in times once a day. Therefore, you need to start early enough to wait for feedback and/or build a vibrant, supportive community that helps each other while we are completing other necessary tasks (research, developing assignments, preparing for lecture, performing advising tasks, etc.).

In this homework, you'll be working through a tutorial in the textbook to create your first game!

Unity Setup

First, read and follow the guidelines in Chapter 17 to download and set up Unity. A few notes:

  • You can do everything you need for this class with the free personal license, but the free student license gives you some more priviliges, so we’d recommend claiming that.
  • The book recommends Version 2020.3 because that's when it was written, but you should get Version 2022.3 for security and modernization reasons. You'll notice later that a few buttons look different and a few features are in slightly different places, but there aren't any major differences you need to be aware of.
  • In the section "Setting up the Unity Window Layout", the book helps you set up a new layout for Unity. We strongly recommend it, as it is much better than the default, but it is not strictly necessary. One thing to note is that the book says you can download their layout but it's nowhere to be found on their website. Thankfully, the manual setup is not only easy but also helpful for you to understand how to move things on your window.

Create a New Project

Follow the instructions in Appendix A to set up a new project. The project will be titled Apple Picker. You'll need to follow the following sections:

  • Setting Up a New Project
  • Setting the Scene Name
  • Setting the Game Pane to Full HD
  • Setting Up a WebGL Build

On to the actual game!

For the rest of this assignment, you'll be creating your own game! For this homework, you'll be creating everything from scratch, so you can get familiar with the entire process of bringing a game into reality. For future homework assignments, we'll be providing more skeleton so that you can focus on the more interesting parts.

You'll be following Chapter 29 in the textbook. Note that, as mentioned before, you’ll find that some buttons are in slightly different places, as the book is a bit outdated. That said, everything discussed in the book can still be done in Unity, so don’t worry if something isn’t exactly where the author describes. Also worth noting is that the HighScore section uses Text, whereas the default in our version of Unity will be TextMeshPro. You can still find Text in the Legacy section of the Unity menu, which you should use for this assignment.

The textbook has you hand-type code from the textbook, which we think is pretty silly. Instead, in the Gradescope assignment for this homework, you'll find all of the code snippets for you to copy/paste into your project, along with some guiding questions to ensure that you're following the code. Head on over to Gradescope now to complete this part of the assignment!

Additional Features

Once you finish implementing the game as described in the book, we'll have you make the game a bit more complex by adding two new types of apples. They are described at the end of the chapter as well, in the Next Steps section. The book also gives a bit of guidance for how to implement each of these. When an apple drops from the tree, it should have a 10% chance of being a Gold Apple, a 10% chance of being a Poison Apple, and an 80% chance of being a normal apple.

  • Gold Apples: Create an apple that is Gold-colored and is worth 200 points instead.
  • Poison Apples: Create an apple that is Purple-colored and is worth 0 points. Furthermore, catching the Poison Apple should count as missing the apple, but missing the apple should not penalize the player.

Hint: You can successfully implement both new types of apples without creating any new scripts (i.e. you don't need to make a goldApple.cs).

Submission

Submit all of your .cs files to the HW2 Code Submission assignment on Gradescope. This includes Apple.cs, ApplePicker.cs, Basket.cs, HighScore.cs, ScoreCounter.cs, and any .cs files related to your Gold/Poison apples if you made them.