Description
The TriggerHaptics
method in the Sandbox.Input
class is used to initiate 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. Additionally, you can define the duration of the haptic feedback in milliseconds.
Usage
To use the TriggerHaptics
method, call it with the desired intensity values for the left and right motors and triggers, along with the duration for which the haptic feedback should last. The intensity values should be between 0.0 (no vibration) and 1.0 (maximum vibration). The duration is specified in milliseconds.
Example
// Example of using TriggerHaptics to create a vibration effect
float leftMotorIntensity = 0.5f; // 50% intensity for the left motor
float rightMotorIntensity = 0.7f; // 70% intensity for the right motor
float leftTriggerIntensity = 0.3f; // 30% intensity for the left trigger
float rightTriggerIntensity = 0.4f; // 40% intensity for the right trigger
int duration = 1000; // Duration of 1000 milliseconds (1 second)
// Trigger the haptic feedback
Sandbox.Input.TriggerHaptics(leftMotorIntensity, rightMotorIntensity, leftTriggerIntensity, rightTriggerIntensity, duration);