해야할 것 : GameObject를 만지면 진동이 오게 만든다.
만들기 위해 준비할 것
1. GameObject Cube를 만들어준다.
2. Cube에다가 Haptic 시스템을 적용할 Scripts를 넣어준다
.3. Scripts 작성
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestHaptic : MonoBehaviour
{
public void OnSelect()
{
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);
}
}
}
OnSelect 상태고 Cube의 Pointable Unity Event Wrapper를 사용하여 When Select 상태일 때 OnSelect() 메서드를 사용하게 했음.
이러면 Cube를 집으면 왼손, 오른손의 float 값을 받아 어떤 트리거가 Cube를 집었는지 확인하고 큐브를 집었을 때 진동을 오게함
----
하지만 이 OVRInput.SetControllerVibration 기능은 진동을 몇 초 울리게하고 그런 기능이 탑재되어있지 않음.
수정 방안이 필요
'Giant vs Human 팀프로젝트 개발일지' 카테고리의 다른 글
[Giant vs Human 팀프로젝트, Meta Quest, VR, Oculus] UI 작업 - 게임시작 시 Start버튼 따라다니기, 남은 거리 보여주기 및 남은 시간 보여주기 (0) | 2023.11.29 |
---|---|
[Giant vs Human 팀프로젝트, Meta Quest, VR, Oculus] 프로토타입 MapScene (0) | 2023.11.29 |
[Giant vs Human 팀프로젝트, Meta Quest, VR, Oculus] Haptic (0) | 2023.11.29 |
[Meta Quest, VR, Oculus] VR로 물체를 빠르게 통과하면 통과가 되는 현상 - 2일차 (0) | 2023.11.03 |
[Meta Quest, VR, Oculus] 대포만들고 쏘기 - 1일차 (0) | 2023.11.03 |