Initial Commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
public class LocalizedHaptics : MonoBehaviour
|
||||
{
|
||||
[Header("Settings")]
|
||||
[SerializeField] private OVRInput.Handedness m_handedness = OVRInput.Handedness.LeftHanded;
|
||||
|
||||
private OVRInput.Controller m_controller;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_controller = m_handedness == OVRInput.Handedness.LeftHanded
|
||||
? OVRInput.Controller.LTouch
|
||||
: OVRInput.Controller.RTouch;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// Build vibration for the frame based on device inputs
|
||||
float thumbAmp = OVRInput.Get(OVRInput.Axis1D.PrimaryThumbRestForce, m_controller) > 0.5f ? 1f : 0f;
|
||||
OVRInput.SetControllerLocalizedVibration(OVRInput.HapticsLocation.Thumb, 0f, thumbAmp, m_controller);
|
||||
|
||||
float indexAmp = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, m_controller) > 0.5f ? 1f : 0f;
|
||||
OVRInput.SetControllerLocalizedVibration(OVRInput.HapticsLocation.Index, 0f, indexAmp, m_controller);
|
||||
|
||||
float handAmp = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, m_controller) > 0.5f ? 1f : 0f;
|
||||
OVRInput.SetControllerLocalizedVibration(OVRInput.HapticsLocation.Hand, 0f, handAmp, m_controller);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9934e1fe91ce6246bc5d27934aa09f8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user