Use Active State

VR/Oculus Integration 2023. 12. 11. 15:35
반응형

 

활성 상태는 구성 요소의 속성을 관찰하고 해당 속성을 해석하여 부울로 표시합니다. 손이나 컨트롤러, GameObject, 인터랙터와 같은 요소의 활성 상태를 확인할 수 있습니다. 요소의 상태를 확인하려면 해당 ...Active State 구성 요소를 사용하세요. 

 

예를 들어 손은 Hand Active State 를 사용 하고

GameObject는 Game Object Active State 를 사용하며

인터랙터는 Interactor Active State 를 사용합니다 . 

 

 

이 시나리오에서는 왼손에 대한 잡기 인터랙터의 상태를 확인합니다.

 

 

인터렉터블 오브젝트 만들고 

 

 

 

인터렉터 붙이고 시작 

 

 

 

 

 

  1. Inspector 아래에 Grab 인터랙터의 상태를 추적하는 Interactor Active State 구성 요소를 추가합니다 .

 

 

 

 

 

  1. 해당 구성 요소에서 Interactor 속성을 OVRCameraRig > OVRInteraction > OVRHands > LeftHand > HandInteractorsLeft > HandGrabInteractor 로 설정합니다 .

 

 

 

 

 

이 튜토리얼에서는 손이 잡는 시기만 감지하려고 하므로 속성 속성을 Is Selecting 으로 설정합니다 .

 

 

 

 

 

  1. 활성 상태가 변경되는 시기를 확인할 수 있도록 활성 상태 디버그 시각적 구성 요소를 추가합니다 .

해당 구성 요소에서  Active State  및  Target 속성을  Cube  GameObject 로 설정합니다 .

 

 

 


 

여러 요소의 상태 확인

이번엔 에셋을 추가 해서 탄창과 총을 모두 들었을경우 튜토리얼 UI를 보여주자 

에셋을 추가 하고 

https://assetstore.unity.com/packages/3d/props/guns/modern-guns-handgun-129821

 
 

 

탄창과 총을 잡을수 있게 만들어 주고 

 

구조를 만들어 주고 

 

 

콜라이더를 추가 하고 

 

잡기에 필요한 컴포넌트들을 부착 한다 

 

 

 

이쁘게 잡고 싶다면 핸드 포즈를 적용한다 

 

 

 

 

 

어색하지 않게 조금 수정 한다 

 

 

 

 

컨트롤러 핸드에서 

 

 

컨트롤러를 잡고 탄창과 총을 잡아 본다 

 

 

 

 

대충 UI를 만들어 주고 

 

 

스크립트도 하나 만들어 주고 

Canvas에 부착 해주고 

 

 

 

Interactor에 Active State 컴포넌트 부착 하고 

 

코드를 간단하게 작성 하고 

using System.Collections;
using System.Collections.Generic;
using Oculus.Interaction;
using UnityEngine;
using UnityEngine.UI;

public class UIActiveStateDebug : MonoBehaviour
{
    public InteractorActiveState activeStateL;
    public InteractorActiveState activeStateR;

    public Image img0;
    public Image img1;
    public Image img2;
    void Update()
    {
        
        this.img0.color = (activeStateL.Active && activeStateR.Active)? Color.green : Color.red;
        
        this.img1.color = (this.activeStateL.Active) ? Color.green : Color.red;
        this.img2.color = (this.activeStateR.Active) ? Color.green : Color.red;
        
    }
}

 

 

 

 


참고 

https://assetstore.unity.com/packages/3d/props/guns/modern-guns-handgun-129821

https://developer.oculus.com/documentation/unity/unity-isdk-use-active-state/

 

 

반응형

'VR > Oculus Integration' 카테고리의 다른 글

One/Two Grab Free Transformer  (0) 2023.12.11
Oculus Integration SDK (R&D 리스트)  (0) 2023.12.11
Debug Pose  (0) 2023.12.10
Hand Pose Detection  (0) 2023.12.10
Controller Ray Visual  (0) 2023.12.08
: