Description
The TriggerHaptics
method is a static method of the Sandbox.Input
class. It is used to trigger haptic feedback on a game controller. This method allows you to specify the intensity of the vibration for both the left and right motors, as well as the left and right triggers, and the duration for which the haptic feedback should be active.
Usage
To use the TriggerHaptics
method, you need to provide the following parameters:
leftMotor
(System.Single): The intensity of the vibration for the left motor. This should be a value between 0.0 (no vibration) and 1.0 (maximum vibration).
rightMotor
(System.Single): The intensity of the vibration for the right motor. This should be a value between 0.0 and 1.0.
leftTrigger
(System.Single): The intensity of the vibration for the left trigger. This should be a value between 0.0 and 1.0.
rightTrigger
(System.Single): The intensity of the vibration for the right trigger. This should be a value between 0.0 and 1.0.
duration
(System.Int32): The duration of the haptic feedback in milliseconds.
Example
// Example of using TriggerHaptics to provide feedback
float leftMotorIntensity = 0.5f; // 50% intensity
float rightMotorIntensity = 0.7f; // 70% intensity
float leftTriggerIntensity = 0.3f; // 30% intensity
float rightTriggerIntensity = 0.4f; // 40% intensity
int durationInMilliseconds = 1000; // 1 second duration
// Trigger haptic feedback
Input.TriggerHaptics(leftMotorIntensity, rightMotorIntensity, leftTriggerIntensity, rightTriggerIntensity, durationInMilliseconds);