Ball game court

Begin building the game assets in Hierarchy. Under ImageTarget create a root object for our game named ThrowingGame and then we'll create ball game graphics under that:

  1. In Hierarchy with ImageTarget selected, create a child empty game object (Create | Create Empty), name it ThrowingGame.
  2. Reset its transform if necessary (Transform | gear-icon | Reset) (as you should any time you create an object in a scene so we start with a clean transform).
  3. With ThrowingGame selected, create an empty game object and name it BoxballGame.
  4. We're going to put the floor and goal into a Court parent object.
  5. In Hierarchy, with BoxballGame selected, create an empty object and name it Court.

For the floor plane, make a Unity 3D plane. Recall that Unity Plane objects are default 10 x 10 units, which we'll use as our default court scale also.

  1. In Hierarchy, with Court selected, create a 3D plane (3D Object | Plane) and name it Floor.
  2. In the Project Assets/ARPlayBall/Materials folder, create a new Material (right-click | Material) and name it BoxballFloorMaterial.
  3. Set its Albedo color to something interesting (we picked a purple #7619FFFF).
  4. Drag the new material onto the Boxball/Floor.

For the goal, as its name implies, we will make a simple box with a matt-like finish, as follows:

  1. In Hierarchy, create an empty object as a child of Court, name it Goal.
  2. As a child of Goal, create a 3D Cube, set Scale (2.2, 0.2, 0.2) and Position (0, 1.5, 1).

 

  1. Duplicate the Cube three times and set their transforms as follows:
    • Position: (0, 1.5, -1), Rotation: (0, 0, 0)
    • Position: (1, 1.5, 0) Rotation: (0, 90, 0)
    • Position: (-1, 1.5, 0), Rotation: (0, 90, 0)
  1. In the Project Assets/ARPlayBall/Materials folder, create a new Material, named BoxballGoalMaterial.
  2. Set its Albedo color to something interesting; we picked a green # 0AAB18FF, and adjusted Metalic: 0.5 and Smoothness: 0.1.
  3. Drag the new material onto each of the Goal cubes we just created.

Lastly, for the ball, let's make it look like a metallic pinball:

  1. In Hierarchy, with BoxballGame selected, create a 3D Sphere and name it Ball.
  2. Set its Scale to (0.75, 0.75, 0.75) and Position to (0, 3, 0).
  3. Create a new material named BoxballBallMaterial".
  4. Set its Albedo to # BABABAFF, Metalic: 0.8, and Smoothness: 0.8.
  5. Drag the new material onto the ball.

The scene Hierarchy should now contain the following:

Save the scene. The resulting scene should look something like the following:

Press Play and point your camera at your image target. The game court should appear but it might be excessively over scale.

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

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