Setting up the scene with ball games

Let's add the new ball games to the scene and add the components they need, which we wrote in this chapter.

For each prefab basketball, football, and paperball:

  1. From the Project Assets/BallGameArt/Prefabs folder, drag the prefab into the Hierarchy as a child of ThrowingGame.
  2. On the ball game object itself, add the BallGame script as a component.
  3. On its ball object, add the ThrowControl script.
  4. On its goal object, add the CollisionBehavior script.
  5. Add to the OnCollision() list, drag the GoalCanvas to the Object slot and set the GameObject.SetActive function, and then check the checkbox.
  6. On the GoalCanvas, add the TimedDisable script.
  7. On the GoalCanvas, add an AudioSource component, drag the Cheer sound file onto the AudioClip slot, and check Play On Awake.
  8. With the ball game object selected, drag its ball onto the Ball Throw Control slot.
  9. Drag its court onto the Court Game Object slot.
  10. Drag its goal onto the Goal Collision Behavior slot.

At this point, you should be able to test each of the games individually one at a time, by disabling all the others under ThrowingGame except the game you want to play. Then, drag that ball game object onto the GameController's Ball Game slot. Try it! Remember, you can adjust the throw control sensitivity and ball speed, as well as the court and goal sizes for each game.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset