Lab 1: Obstacle Course


Submit on canvas before your lab starts

  1. Fill out this google form for group formation (Complete by Sunday night).
  2. Download the code for this lab and make sure you can open it in unity
  3. Watch this video (10m long) to get further acquainted with Unity and review what we covered in lab 0.
    • (Optional) Watch the rest of the videos in the series to learn more about unity
  4. Imagine a robot moving in a tunnel with some obstacles in its path that it needs to navigate around. The obstacles can leave either the left or right side open (or neither!). To navigate past the obstacles, whenever it hits an obstacle, the robot needs to determine whether it needs to move to the right or left to get past the obstacle, or to stop if neither option is available. Write the pseudo-code (Help: What is pseudo-code?) for the robot’s movement in the tunnel.It’s OK to leave this pseudo-code fairly high-level and informal, but it should touch on the broader issues that need to be tackled for this navigation task.



Part 1:

Load in Part1 scene (just a blank world) and explore the basics of the Unity interface

    • TODO: Finish designing a simple block moving continuously in a straight line on a flat platform and show it to your TA when you are done
      1. First, create the ground as a flat cube and add GroundMat as a component to the ground object
      2. Create a basic cube as the player object and add the PlayerMat and Rigidbody component to it
        • Why is the Rigidbody component necessary?
      3. Figure out how to change colors of the ground and player
      4. Add some more 3D objects on the ground to serve as obstacles
      5. Add the P1PlayerMovement script as a component to the Player object. This is where you can specify the logic for the player’s movement
        • In the Inspector screen for the Player object, find the added script and specify the rb variable to refer to the Player object. This is so that the code can refer to the player itself when specifying movement
      6. Open the P1PlayerMovement script and implement the Update() function so that the player object automatically moves forward.
        • Hint: use the AddForce() method for Rigidbody objects
      7. Try running the program. Is the player moving smoothly? If not, why is that?
        • Hint: look at the given assets

BONUS: figure out how to get the camera to follow the player object

  • Hint: look at the given assets

Part 2:

  1. Load in Part2 scene (the simple obstacle course)
  2. Open the P2PlayerMovement script
  3. TODO: Finish implementing the Update() and OnCollisionEnter() functions so that the player object can navigate through the obstacle course
    • Follow the specifications given in the file
    • Hint: think back to the pseudo-code logic from the pre-lab if you are stuck

BONUS: Implement the ChangeColor() function to change the player object’s color based on the color input

  • Calling ChangeColor(“red”) should change the box to red
  • If you can get it to work, try inserting it in different functions in the P2PlayerMovement script and see how the color reflects the logic in your code


Submit your P1PlayerMovement and P2PlayerMovement code files as well as the answers for the following questions Canvas by midnight the day after your lab:

  1. What type of logic was used to determine whether the player object should dodge?
  2. Let’s think about this simulation using some of the tools from physical symbol systems. What symbols does this machine use to represent its own movements (think about our boolean variables)? What do these symbols designate in the simulated world?
  3. Which part of this lab did you find most challenging?
  4. What do you think could be improved about this lab? (Optional and not for marks, but feedback is greatly appreciated!)