The are two main components involved in setting up an interactable object. The object that can start the interaction (the Interactable), and the object that does the interaction (the Interactable Target). In the Third Person Shooter demo, the object that starts the interaction is the switch and the object that does the interaction is the moving platform.
In this example we will use the adventure scene to open a door after interacting with another object. In this example the other object is a lever, but it could be anything. The first step is to add the Interactable component to the object that you want to use to start the interaction:
The Interactable component has various settings for determining if the character can interact with the object. It can be any MonoBehaviour as long as it implements to the IInteractable interface. In addition, it has a trigger collider which is used to ensure the character is near the Interactable object. The Interactable component has two especially important values: the ID and Target. The ID is used by the character controller to determine which Interact ability to use when an interaction takes place. Multiple Interact abilities can be placed on the character. This ID maps a particular Interact ability to a particular Interactable object. A value of -1 can be used if there are not going to be multiple types of interactions.
The second import value on the Interactable component is the Target. The Target is the object that does the actual interaction. As soon as all of the settings are satisfied (such as the character looking at the Interactable object and being in the correct layer), this Target object will actually perform the interaction. In our example, the Target object is the actual lever:
The Interactable Target can be any MonoBehaviour that implements the IInteractableTarget interface. The Door Open Interactable component is used in this example. This component will play an animation and toggle the light state when the Interactble component is interacted with.
<- Setup a Ladder