Skip to content

Commit

Permalink
Ensure haptics on correct controller via GetComponentInParent(), close
Browse files Browse the repository at this point in the history
  • Loading branch information
John Luxford committed Aug 29, 2017
1 parent b1911e4 commit 478e5c6
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Assets/VRKeys/Scripts/Platforms/OpenVRHaptics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ namespace VRKeys {

public class OpenVRHaptics : Haptics {

private int deviceIndex = -1;

private SteamVR_Controller.Device controller;

public override void TriggerPulse () {
int deviceIndex = (mallet.hand == Mallet.MalletHand.Left)
? SteamVR_Controller.GetDeviceIndex (SteamVR_Controller.DeviceRelation.Leftmost)
: SteamVR_Controller.GetDeviceIndex (SteamVR_Controller.DeviceRelation.Rightmost);
if (deviceIndex == -1) {
var trackedObject = GetComponentInParent<SteamVR_TrackedObject> ();
if (trackedObject == null) return;

if (deviceIndex == -1) return;
deviceIndex = (int) trackedObject.index;
if (deviceIndex == -1) return;

var controller = SteamVR_Controller.Input (deviceIndex);
controller = SteamVR_Controller.Input (deviceIndex);
}

controller.TriggerHapticPulse (800);
}
Expand Down

0 comments on commit 478e5c6

Please sign in to comment.