The mallet

The next prop is the mallet, but let's clarify what we mean by a mallet. Mallets are typically long hammer-style tools used in woodworking or croquet. In carnival games, a mallet is used to hit or smash things for points and prizes. But in our virtual world, a mallet can take any shape you desire. For our purposes, the more outlandish the shape the better the experience. Figure 8.3 shows a few different mallet ideas, but we highly recommend being creative and experimenting with different shapes:

Figure 8.3: Various mallet shapes: mallet, boxing glove, and paddle

Whichever shape you use, there are a few components needed to interact correctly with scene elements. First there are the colliders. These are needed to determine if two objects touch each other. Later we will edit the MoleController script to recognize a collision and update the Score Board accordingly. But for that script to work, we need to make sure our mallet has at least one (mesh, box, or capsule) collider attached to the outermost GameObject container.

And secondly, we need the OVRGrabbable script. OVRGrabbable provides the ability to grab and throw objects. This script is amazing in that it handles so many situations and is as easy to use as any drag and drop tool. We only need to adjust a few attributes when applying the script to our mallet. For more information on the OVRGrabble script, visit the Oculus Utilities for Unity web page at https://developer.oculus.com/documentation/unity/latest/concepts/unity-utilities-overview/.

The following steps illustrate how to build and set up the typical carnival mallet. But the sky is the limit, and we hope you will explore other options as well:

  1. Add a new empty GameObject to the MoleGame asset. Rename the object Mallet and position it near the GameTable.
  2. Add the Rigidbody component to the new GameObject.
  3. Add a new Cylinder to the Mallet GameObject, rename the object MalletHead, and set its rotation and scale as indicated here:
    • Rotation = (0, 0, 90)
    • Scale = (0.2, 0.09, 0.2)
  1. Duplicate the MalletHead. Change its name to MalletHandle and set its scale to (0.05, 0.21, 0.05).
  2. Reposition the MalletHandle to create the desired shape.
  3. Select the Mallet GameObject and add the OVRGrabbable script from the OVR/Scripts/Util directory.

With the basic props in place, we can reactivate the Midway environment. Select the Environment, WackyMoles, and TeleportSystem GameObjects and reactivate them in the Hierarchy panel:

  1. Transform the MoleGame to fit in the WackyMole booth. For our scene, we used the following values:
    • Position = (0, 1.05, -1.35)
    • Rotation = (-15, 0, 0)
    • Scale = (0.75, 0.75, 0.75)
  1. Select the MoleGame | ScoreBoard and set its Rotation to (15, 0, 0). In the previous step, the Score Board was rotated forward to give the player better access to the game area. This step rotates the Score Board back to a vertical position.
  2. Relocate the MoleGame | Mallet object so that it is sitting over the counter of the WackyMole booth. When the game is running, the mallet will drop down to the counter.
  3. Drag the MoleGame GameObject into the WackyMoles object to keep everything organized.
..................Content has been hidden....................

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