cancel
Showing results for 
Search instead for 
Did you mean: 

Haptics SDK for Unity not working

thatnzguy22
Honored Guest

I'm trying out the new Haptics SDK for Unity

I want to test it by playing a single haptic, but when I use this script I get an error with no haptics (testing in Unity editor 2022.2.13, with Air Link to a Quest 2)

Script:

public class OculusHapticClipTest : MonoBehaviour
{
[SerializeField] private HapticClip _hapticClip;
private HapticClipPlayer _hapticClipPlayer;

private void Start()
{
_hapticClipPlayer = new HapticClipPlayer(_hapticClip);
_hapticClipPlayer.Play(HapticInstance.Hand.Left);
}
}

Error:

Error: HapticsSDK has already been initialized
UnityEngine.Debug:LogError (object)
Oculus.Haptics.HapticInstance:Initialize () (at ./Packages/com.meta.xr.sdk.haptics/Runtime/HapticInstance.cs:101)
Oculus.Haptics.HapticInstance:MakeClipFromJson (string) (at ./Packages/com.meta.xr.sdk.haptics/Runtime/HapticInstance.cs:127)
Oculus.Haptics.HapticClipPlayer:.ctor (Oculus.Haptics.HapticClip) (at ./Packages/com.meta.xr.sdk.haptics/Runtime/HapticClipPlayer.cs:77)
OculusHapticClipTest:Start () (at Assets/CombatProto/Impact CFX Haptic/OculusHapticClipTest.cs:14)

I can't find anything else that may be calling new HapticClipPlayer() anywhere else in the scene.

Any tips? Thanks

1 REPLY 1

thatnzguy22
Honored Guest

Ah okay it works in a build, but not in Unity Editor using Link.

Please fix this