Giant vs Human 팀프로젝트 개발일지

[Giant vs Human 팀프로젝트, Meta Quest, VR, Oculus] Haptic

다모아 2023. 11. 29. 19:45

Haptic 기능에서 이제 추가로 원하는 작업이 무엇이든 닿으면 진동이 울리게하는게 목표였다.

 

 

Pointaable Unity Event Wrapper로 Select 되었을 때 진동기능을 해주었다.

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TestHaptic : MonoBehaviour
{
    
    public void OnSelect()
    {
        this.vibratorSensor();
    }

    private void OnTriggerEnter(Collider other)
    {
        this.vibratorSensor();
    }

    private void vibratorSensor()
    {
        float primaryIndexTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger);
        float primaryHandTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger);
        float secondIndexTrigger = OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger);
        float secondHandTrigger = OVRInput.Get(OVRInput.Axis1D.SecondaryHandTrigger);

        //왼손
        if (primaryHandTrigger > 0)
        {
            OVRInput.SetControllerVibration(1, 1, OVRInput.Controller.LTouch);
        }
        //왼손
        else if (primaryIndexTrigger > 0)
        {
            OVRInput.SetControllerVibration(1, 1, OVRInput.Controller.LTouch);
        }
        //오른손
        else if (secondHandTrigger > 0)
        {
            OVRInput.SetControllerVibration(1, 1, OVRInput.Controller.RTouch);
        }
        //오른손
        else if (secondIndexTrigger > 0)
        {
            OVRInput.SetControllerVibration(1, 1, OVRInput.Controller.RTouch);
        }
    }
}