Adding TestingInput to the scene

Singletons can be called from anywhere and everywhere, and they actually don't need a game object in the scene. However, by adding the object to the scene, we become more self-aware of the required dependency, as it allows us to set required parameters for a particular scene. Open the Unity editor and follow the next exercise to add the TestingInput component to the scene:

  1. Click in the Hierarchy window, and from the menu, select Game Object | Create Empty.  Rename the object TestingInput.
  2. Drag the TestingInput script from the HoDLG | Scripts folder in the Project window to the new TestingInput object in the Hierarchy window.
  3. Select the TestingInput object, and then set the required Axes, as shown in the following screenshot:

Setting the axes to override
  1. We need to define two Axes that we want to override. In this case, we are only overriding the Vertical (S and W) and Horizontal (A and D) keys. You could, of course, override any axis that you wanted, but in this case, we are only overriding two.
  2. Save the project and the scene. 

At this point, you can't really run the project, since the actual input system isn't overriding anything just yet. We complete that final injection in the next section.

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

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