SkeeSpawner

In the flow of the program, once we have the machine placed how we want, we need a start button, which we deleted earlier. If you have ever played one of these games in the real world, how did you start the machine? You did so by putting a quarter or token in the machine. With that in mind, does it not make sense to use the coin slots as the start button? Well, that is what we will do.

In this case, we will only need an empty game object with a collider. We will fit that object around the coin slots so that the user can click on the coin slots to start the game.

When you are in the flow of creating a project, there are definitely different approaches you can use. For instance, we can easily create a box, attach it to the Prefab, move it to the correct location, and so on. However, it seems better to me that if we have an object in this project already, or even in the very Hierarchy of objects we are using, that is very similar to our needs, it will be a better solution than creating a new object from scratch.

Here, we will take the colliders we created for the targets and repurpose them for our needs to make a Start button/SkeeBall Spawner. Let's take a look at the following steps:

  1. Select the 10Collider object, right-click, and hit Duplicate:
  1. Rename the object SkeeSpawner and move it to the UI section of the Prefab.
  2. Set the object's transform position to X = -33.96297, Y = -6.33325, and Z = -822.9261.
  3. Set its X rotation to be 0 and its X, Y, and Z scales to be 37.
  4. In the objects Box Collider, turn the IsTrigger checkbox off.
  5. Finally, remove the ScorePoints component by right-clicking on the gear icon of the component and selecting the Remove Component option:
  1. Now, as we have done before, click on Add Component | New Script.
  2. Type SkeeSpawner in the box and click on Create and Add:
  1. Now, double-click on the newly created component to bring it up in Visual Studio:
  1. Replace the code in the fresh SkeeSpawner with the preceding script. First, we have a reference to the Spawn Point we created in the last section. Secondly, we have a reference to our Gameball Prefab, which we will be creating soon. Lastly, we are using the HoloLens InputModule to react to the OnInputClicked event. If the button gets clicked, the ApplicationManager is informed by having a bool set to true, which the application manager reacts to and then immediately sets the bool back to false.
  2. Open up your ApplicationManager script in Visual Studio and add this at or around line 23:
  1. If we look at the SkeeSpawner object, the SkeeSpawner (Script) component now has two input boxes waiting for GameObjects.
  2. Drag the BallSpawnPoint to the field next to Spawn Point.
  3. The other field is looking for our Skeeball Prefab, which we have not yet made, so we will have to address this in a bit:

Onward and upward as they say.

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

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