Spawning our Skeeball machine

Different systems handle object instantiation in different ways. For the single-user version of the project that we have created over the past couple of chapters, we did not use spawning or instantiating at all. We have had the object turned off, and would turn it on only when certain conditions are met. Before we continue, we need to correct that. Let's perform the following steps: 

  1. In the Hierarchy view, select the skee object.
  2. Click on the Apply button in the Inspector just to be sure.
  3. With the object still selected in the Hierarchy view, right-click on the object and click on the Delete option.

Now, we need to set up our system that will allow us to spawn in our skee Prefab; we will use a component with the name Prefab Spawn Manager:

  1. With the Sharing object selected in the Hierarchy view, click on the Add Component button in the Inspector.
  2. Type Pref into the search bar and select Prefab Spawn Manager, as follows:

Now, let's put in the information we need to get this working:

  1.  Click on the arrow next to the Spawnable Prefabs.
  2.  Put the number 1 in the size box and press the Tab key.
  3.  Type SyncSpawnedObject into the Data Model Class Name box.
  4.  Click on the small donut past the Prefab box.
  5. Select Skee. Ensure that it is the object in the Prefabs directory; you will notice the object path in the window under the Select GameObject box, as shown in the following screenshot:

The SyncSpawnedObject class in a sense converts data into a format that allows the system to track and broadcast or synchronize the information out to various clients.

In the Project view, go to the Prefabs directory and select the skee object:

We need to add components to the object. Using the Add Component button again, add DefaultSyncModelAccessor; this works with the SyncSpawnedObject to update the transform information among clients. Then, add ImportExportAnchorManager. This handles world anchors between clients.

That's it for the skee Prefab in this chapter.

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

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