Challenge - Basketball and the Hierarchy

Tutorial

·

Beginner

·

+10XP

·

60 mins

·

(23)

Unity Technologies

Challenge - Basketball and the Hierarchy

Challenge Overview:

Use the skills you’ve learned in the previous two lessons to score on a basketball hoop. After you’ve scored, you will have to use the hierarchy and inspector windows to manipulate the way your catapult works. When you’ve found out how to make changes to your catapult, try the Free Play activities again using different catapult settings. When you’ve finished working with the catapult settings, look at the code that calculates the values you see inside the simulation.

Challenge Outcome:

  • Catapult will throw a cannonball through a basketball hoop
  • Catapult settings and characteristics will be manipulated
  • Editor code will be investigated

Challenge Objectives:

In this challenge, you will reinforce the following skills/concepts:

  • Using mass and force sliders to send a cannonball to a specific location
  • Use the hierarchy menu to select elements of your catapult
  • Adjust the launch settings of your catapult using the inspector window in Unity
  • Complete the Free Play activities without the use of the force and mass sliders
  • Adjust the project settings and investigate the effect of your changes in the Free Play activities
  • Look at the code that allows the physics editor to make calculations

Languages available:

1. Overview

Use the skills you’ve learned in the previous two lessons to get the cannonball through the basketball hoop. After you’ve scored, you will have to use the Hierarchy and Inspector windows to manipulate the way your catapult works. When you’ve found out how to make changes to your catapult, try the Free Play activities again using different catapult settings. When you’ve finished working with the catapult settings, look at the code that calculates the values you see inside the simulation.


2. Score a basket

In this challenge, you must set the values to throw the ball through the hoop:



1. Enter Play mode and select the Basketball [Challenge] button.


2. Use the Cannonball Force and Spring Mass sliders to find a set of values that will allow you to catapult the ball through the hoop.


Hint: Use what you've learned in the previous free-play activities and manipulate the spring force and mass sliders.



3. Adjust the trajectory without the sliders

Until now, you’ve used the provided sliders to change the behavior of the catapult and cannonball. Unity exposes all of the various settings to the user so that they can build an application like this without the need for a slider interface.


Your challenge is to adjust the mass of the cannonball without the use of the sliders.


1. Enter Play mode and select the Free Play [Boxes] button.


2. Find the Cannonball GameObject in the Hierarchy window.



3. Use the Inspector window to check which variables are available to you.


4. Adjust the variables and run the simulation without changing the Cannonball Mass slider and see if you can knock the boxes over.


Tip: The cannonball's mass can be changed in the RigidBody component of the Cannonball GameObject.


4. More things to try

Below are a couple of other things to try once you feel confident about you abilities:


  • Change the launch angle of the catapult arm.

Tip: You need to find the GameObject that contains these settings.


  • Inspect the code to see how the forces and movement are calculated in the context of the Unity physics system.

Tip: You will find the scripts in the Assets > Scripts folder.


Congratulations, you have finished the Catapult Physics: Forces and Energy tutorial! In this tutorial, you learned how to calculate the forces, velocity and energy associated with a moving projectile.


Complete this tutorial