We have provided a Unity package with several ball games, including basketball, football, and a paper ball. Each game has assets for goals, court floor, and balls, as shown in the following images:
The following are the corresponding ball assets we provide for each ball game type:
We've designed the assets so each court, goal, and ball are together in its own prefab.
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:
- From the Project
Assets/BallGameArt/Prefabs
folder, drag the prefab into theHierarchy
as a child ofThrowingGame
. - On the ball game object itself, add the
BallGame
script as a component. - On its ball object, add the
ThrowControl
script. - On its goal object, add the
CollisionBehavior
script. - Add to the
OnCollision()
list, drag theGoalCanvas
to theObject
slot and set theGameObject.SetActive
function, and then check...