Most interactable objects in VRIF will utilize Unity Events to allow you to react to common interactions. For example, the button object has an "OnButtonDown" and "OnButtonUp" event you can use to make it easy to call functions when the button is pressed or released. A lever object has an "OnLeverDown", "OnLeverUp", and "OnLeverChange" event.
To assign a function to your event, create or use a script that contains a public function that contains your code that you want to execute once this event occurs. For example, let's say I have a VehicleController script in the scene, and I want to call the "SetMotorTorqueInput" when the joystick value changes. To do this (from the Unity docs) :
Select the + icon to add a slot for a callback
Select the UnityEngine.Object you wish to receive the callback (VehicleController in this example)
Select the function you wish to be called (SetMotorTorqueInput in this example)
You can add more then one callback for the event
There are two types of Unity events : Static Events, and Dynamic Events. Static events allow you to set the value right in the UI, whereas a dynamic event will pass a value along to the function. The joystick change event is dyanmic, since it is passing a Vector2 along, letting the function know what our current joystick axis is.
Make sure you are using the proper event type. Dynamic events are at the top :
Buttons, switches, and levers are generally controlled by using physics joints, such as a Fixed Joint and Configurable Joint. This allows the actuators to be moved around using physics forces, which can make for some interesting gameplay mechanics.
For example, a lever consists of a Grabbable part that is attached to a base via a ConfigurableJoint. That base could also be a Grabbable object. Whenever the player grabs the lever, a joint is attached, but is still constrained to the base.
*Note - Sometimes the Physics Engine can become unstable if certain conditions are met, so a helper script '/Scripts/Helpers/JointHelper.cs' is available that will help constraint objects to where they should be. This script essentially locks the transform into place during the Update() loop, ignoring physics entirely. This can ensure smooth movement on certain interactions, but I would recommend setting up most interactions without it first, if possible, as it is extra overhead and more of a bandaid to fix certain jitter instances. If you can create an interaction without it - start there first.
You may not always want your input objects to be affected by physical forces. If you are on a moving platform, or very fast moving vehicle, these external forces can cause your button, lever, etc to behave wildly and jitter or jump around as the heavy forces push against the Rigidbody, but the physical joint struggles to keep it in place.
There are two methods of using non-physical interactables (button, lever, steeringwheel, etc) :
Use one of the dedicated prefabs : Some prefabs are designed specifically to be used on prefabs. They do not contain any Rigidbodies or joints, and are instead controlled by directly manipulating a Transform's position / rotation. This ensures a perfectly smooth interaction regardless of the velocity of whatever it is parented to. The "JoystickVehicle" prefab and "SteeringWheel" prefabs do not use physics and are great options to use in a fast moving vehicle.
Alternatively, most objects will have a "Allow Physical Forces" option on them. Disable this and set the Rigidbody of the object to Kinematic to ensure the object is always kinematic. Kinematic objects are not affected by external forces. You can then parent this object to your vehicle / moving platform. If you do not want to parent the object, you can have it follow a Transform on your vehicle by using the FollowTransform script or FollowRigidbody script.
Check out this video by Johnny5 on levers, switches, and more :