Adding the environmental scanner

Now that we have a script that uses the component, let's add it to our scene as a new object. Return to the editor where we last left off and continue as follows:

  1. Open the HelloAR scene. From the menu, select File | Save as and save the scene as Main in the Assets/ARCoreML folder.
  2. Find and select First Person Camera in the Hierarchy window. Remember that you can use the search panel.
  3. Right-click (Ctrl + Click on Mac) on the First Person Camera and from the context menu, select Create Empty. Name the object as Environmental Scanner.
  4. Select the new object and in the Inspector window, add a new AudioSource component.
  5. Create a new folder called Audio in the Assets/ARCoreML path in the Project window.
  6. Open the Resources folder from the downloaded code folder and copy the tone-beep.wav file to the new Assets/ARCoreML/Audio folder you just created.
  7. Open up the Environmental Scanner object in the Inspector window and set the AudioSource properties, as shown in the following screenshot:
Setting the AudioSource properties in the Inspector
  1. With Environmental Scanner still selected, click on the Add Component button in the Inspector window. Add the Environmental Scanner script we wrote earlier.
  2. Open the Build Settings dialog and ensure that you add the current scene (Main) to the build. Ensure that you remove any other scenes from the build.
  3. Connect, build, and run. Move around the room. Now what happens when you get too close to objects? At what distance?

Great, so we have effectively made a backup or warning beeper to let you know when you are getting too close to an object. Obviously, we could have just as easily written a simple threshold test ourselves to test when min is getting too close. However, this simple example gives us a good basis for understanding how training works.

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

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