I’m trying to get my touch controllers to vibrate. I’ve tried with OVRPlugin.setcontrollervibration but have had no luck. Has anyone succeeded in getting their controllers to vibrate?
1 Answer
1After looking around and try to understand what i was reading I finaly got it to work and wrote a simple demo to see if I understod it correctly. Here it is.
using UnityEngine;
public class TeleportScript : MonoBehaviour {
//Audio input used for vibrate left controller
public AudioClip AC;
// used to make a saw wave
private int wave = 0;
// Update is called once per frame
void Update () {
//checks if any button is pressed on the touch controllers
OVRInput.Update();
//Left hand controller index button
if(OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger,OVRInput.Controller.Touch) > 0f) {
//outputs vibration to left controller
OVRHaptics.Channels[0].Preempt(new OVRHapticsClip(AC));
}
//Right hand controller index button
if (OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger, OVRInput.Controller.Touch) > 0f) {
//the value determens the power of the vibration
//scale from 0 to 255
byte[] noize = { 255 };
// tho 40 was about when I coulde start feel it
//byte[] noize = { 40};
//outputs vibration to left controller
OVRHaptics.Channels[1].Preempt(new OVRHapticsClip(noize, 1));
}
//right hand trigger button
if (OVRInput.Get(OVRInput.Axis1D.SecondaryHandTrigger, OVRInput.Controller.Touch) > 0f) {
//make a saw wave
wave++;
if (wave >= 255) {
wave = 0;
}
byte[] noize = { (byte)wave };
//outputs vibration to left controller
OVRHaptics.Channels[1].Preempt(new OVRHapticsClip(noize, 1));
}
//this updates the controlls
OVRHaptics.Process();
}
}
On the left controler I used a audiofile wich was a 30 sec long sin wave and the controller woulde vibrate untill the hole clip has been played tru.
Perhaps this is what you are looking for: https://developer.oculus.com/documentation/unity/latest/concepts/unity-ovrhaptics/
– DestolosHandheld.Vibrate ();
– Ali-hatem