Skip to content

HW 2: Roll-a-ball

This assignment will help you get acquainted with the Unity game engine, the Unity editor, and creating your own games.

Part 1: Base Implementation

For the first part of the assignment, your goal is to complete the Roll-a-Ball tutorial. This tutorial will guide you through the main mechanisms of the Unity game engine and help you create a mini game with a controllable character and collectable items. While completing this tutorial, focus on getting familiar with writing components (or "behaviors"), as they are fundamental to Unity development.

Note

If you followed along in class, you should have already completed a few parts (Setting up the Game, Moving the Player, and Setting up the Play Area). Continue the tutorial from the "Moving the Camera" and then skip to the "Creating Collectibles" section.

Part 2: New Feature

Now that you've followed the tutorial, it's time to have some fun and experiment on your own! Your goal is to expand upon the roll-a-ball game and add some new features.

You are encouraged to do your own research (Google things, watch videos, talk with classmates) to accomplish these goals. Just make sure to cite any resource that helps you. I recommend putting a link to the resource in a code comment and simply stating how it helped you, for example:

// I used the following website to learn how to move objects (btw, super helpful)
// https://gamedevbeginner.com/how-to-move-objects-in-unity/
transform.Translate(Vector3.up);

Using your existing game, add one of the following new features. Make sure to read all the guidelines for the feature you pick:

  • Make the ball be able to jump when the spacebar is pressed

    • Required: Place some new collectables in the air too for the player to collect
    • Required: If the ball falls off the edge, teleport it back to its starting position
      • One way is to check the ball's transform.position.y every update and reset the ball's position if it falls too far
      • Another way is to create a trigger a few meters underneath the floor instead of checking the ball's position
    • You can modify the PlayerController.cs to handle spacebar input:

      • Inside the FixedUpdate() function, you can check if the spacebar is pressed that frame using Input.GetKeyDown:

        if (Input.GetKeyDown("space")) { ... }
        
      • Or, you can also create a new "jump" action using the Unity Input System and then handle it like you did with movement

  • Increase the size of the ball based on the number of collectables collected

    • Required: The ball should increase its size uniformly (in all XYZ dimensions) with each new collectable
    • Required: You should limit the maximum size the ball can grow after 8 collectables
    • It may be easiest to modify your PlayerController.cs script, although it isn't required to do so
    • Remember, each GameObject has a transform variable that represents its position, rotation, and scale.
  • Evil cylinders that move back and forth and "pop" your ball when touched

    • Required: When the ball touches a cylinder, teleport the ball back to its starting position
      • Just like with the collectables, you can add a "tag" to the cylinders to distinguish it from other collisions
    • Required: Create a new script/component called MoveBackAndForth.cs to model the behavior
    • For instance, cylinders could move right for 1 sec, then left for 1 sec, then right for 1 sec, etc.

      Tip

      Remember how you made the collectables rotate? You used the Time.deltaTime to see how much time has passed since the last frame. You can create an instance variable to keep track of how much time has elapsed since the cylinder last changed direction.

Submission

Go to the folder containing your Unity project. You can use Unity Hub to quickly do so.

Open the folder corresponding to your project. Inside, you should see a lot of subfolders, including Assets, Library, etc.

Create a zip file containing only the Assets, Packages, and ProjectSettings folders. The other files are generated by Unity and not needed for submission.

Submit this zip file to Gradescope.

Grading

Your submission will be graded based on the following criteria:

Criteria None Poor Okay Good Total
Base Implementation 0 pts
Did not follow the tutorial
2 pts
Partially completed tutorial
4 pts
Some parts missing or not working
5 pts
Fully working base roll-a-ball implementation
5 pts
New Feature 0 pts
Did not add new feature
2 pts
Partial implemention or didn't follow instructions
4 pts
Working implementation, but missing some of the specs
5 pts
Fully implemented new feature
5 pts
10 pts

Minor points may be added/deducted at the instructor's discretion, based on code quality, bugs, not following instructions, I have no idea what any of your code does, etc. See Gradescope for full grading details.