When bounding boxes collide

So, we have accomplished the organization and simple importing processes. That wasn't much of a challenge, was it? Well, now it is time for something with a little more substance.

In this section, we will build seven trigger colliders so that our application will register a score when they are hit by the balls. We will then write a simple script that tells the application manager to change the score based on the trigger that was hit.

To start, we need somewhere to put our collection of collider boxes. As we did with UI and Static Lights earlier in the chapter, create an empty child object of skee, called TargetColliders.

The Mesh Renderer of a Unity GameObject is what determines the visibility of that object. It stores the materials and lighting information. In my experience, I have found that building an actual mesh object and then removing or turning off the Mesh Renderer produces better results in terms of collisions.

The scoring system in our game will be the classic 10, 20, 30, 40, 50, 100. We will start with 10 and build and copy till we are done. Look at the following steps:

  1. Right-click on the TargetColliders GameObject in the Hierarchy view.
  2. Click on 3D Object.
  3. Then, select Cube as the type of 3D object to create:
  1. In the Inspector, change the object's name to 10Collider:
  1. In the Inspector view, we need to change the transform of the object, as follows:
  • Position X: -155.2 Y: 65.7 Z: -43.99997
  • Rotation X: 35.86 Y:0 Z:0
  • Scale X: 31 Y:31 Z: 31
  1. Click on the checkbox labeled IsTrigger:
  1. Uncheck the checkbox that says Mesh Renderer:
..................Content has been hidden....................

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