Some quick upkeep

We need to get set up so that we can get rolling through the rest of the chapter.

First, open Unity and do the New Chapter Shuffle, as I am now calling it. Save the final version of the chapter6 scene as Chapter7.unity. I will have a Chapter7downloads.zip for any important files, but as always, I recommend that you type it out to learn it.

Once you are loaded up with our fresh Chapter7 file, you should see something that looks like this:

If you look in the Hierarchy view, you should see the Sphere object is inactive. Select it and press the Delete key; we don't need it.

So, when I finished the last chapter and started working on this one, I realized one thing I did was a bit inefficient. I had a separate Collider object instead of using the Collider that was already present on our root object. I had my reasons for it, but in the end, that would make some of the steps going forward too complicated. So, we will fix that really quick by adding a Collider to our root object.

Expand the skee object and select the TaptoPlaceCollider, then press the Delete key:

Select the skee object. This is what you should see in the Inspector window:

Click on the Add Component button, type B into the search bar, and click on Box Collider in the list:

Look at the Box Collider component. We will adjust the center and size elements of this component as follows:

  • Center: X: -152 , Y: 39, Z: -335
  •  Size: X: 304 , Y: 463 , Z: 1189:

What we just did was adjust the size and placement of the collision box. You may note that the collision box is a bit larger than the object it is surrounding, that is on purpose. This collision box will only be used when we are initially placing it. Once placed, we will code it to turn off.

Now, let's attach the code we will be working with our object. With the skee object still selected, click on the Add Component button again. Type Pla into the search box and select the PlaceSkeeBallMachine script:

With setup out of the way, we are ready to go.

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

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