Posted October 11, 2023 by Sarah Reen
Programming - 6 hours
I continued my work on implementing the Interaction System which will be vital in implementing the various Gizmos and "Gadgets." Gizmos refer to the 4 main objects the two players will be interacting with (Lever, Button, Crank, Slider), and Gadgets refer to the objects that are affected by those Gizmos (Door, Laser, Air Turbine, etc.) When a player interacts with a Gizmo, it needs to do two main things:
All Gizmo Objects Inherit form a base Parent known as InteractableBase. This class sets up the needed functions for what is required in Step 1. It sets up an interaction event and then updates its value based on that specific interaction event. It then calls another function that Updates the Specific Gadget.
However, we will have several different types of gizmos that all have unique attributes and characteristics. It would be better to place that logic in its separate script that inherits from InteractableBase. This keeps our code clean and organized, without running the risk of certain objects having access to things they shouldn't have. For example, in the Lever Script, it can update its value to either 0 or 1; the only two values that it can have are reflected by the Up or Down state. But in comparison, the Crank Script updates its value between a range of 0 to 1 based on the position of its child object in a 360-degree rotation.
We then need to retrieve data about the specific Gadget that we want to update given the value of the Gizmo. This is done similarly to how we retrieve the Gizmo: with scriptable Object. When interacting with an object, the InteractionBase searches for the Gizmo Data of the given object. It then populates itself with that data to perform certain functions successfully. The InteractionBase will also then have to search for the relevant Gadget Data based on several properties such as which wire the gizmo is attached to, and what Gadget is also attached to that wire. This part of the script is still a work in progress.