- Home /
Vibration on haptic device when it collides with a game object
I'm using Unity 5 Haptic Plugin for Geomagic OpenHaptics as a reference for my project (and am very new at it). There is an example Custom_Force_Effect which tiggers the vibration when the button on the haptic device is pressed. What i want is for the vibration to occur when it collides with a game object. The problem is that i am not able to identify the code that will allow the button to trigger the vibration with the button hence no matter where i add my vibration code it still needs the button tigger in order to occur. Any ideas?
public void SetVibrationMotor()
{
myVibrationMotorScript = transform.GetComponent<VibrationMotor>();
/*****************************
* Vibration Motor Force Example
*****************************/
//convert String to IntPtr
IntPtr type = ConverterClass.ConvertStringToByteToIntPtr(myVibrationMotorScript.Type);
//Convert float[3] to intptr
IntPtr position = ConverterClass.ConvertFloat3ToIntPtr(myVibrationMotorScript.positionEffect);
//Convert float[3] to intptr
IntPtr direction = ConverterClass.ConvertFloat3ToIntPtr(myVibrationMotorScript.directionEffect);
//Set the effect
PluginImport.SetEffect(type,myVibrationMotorScript.effect_index, myVibrationMotorScript.gain, myVibrationMotorScript.magnitude, myVibrationMotorScript.duration, myVibrationMotorScript.frequency, position, direction);
PluginImport.StartEffect(myVibrationMotorScript.effect_index);
}
Comment