Oculus Go로 바삭 바삭한 차
Oculus Go로 자동차를 이동
Unity는 Standard Assets에서 Vehicles라는 자동차 거동을 쉽게 이용할 수 있는 자산을 제공합니다.
이것을 OculusGo에 대응시켜, FPS 시점에서 조작할 수 있도록 해 보았습니다.

절차
Vehicles 가져오기
Assets > Import Package > Vehicles에서 자산 패키지를 가져옵니다.

Car 조립식을 Hierarchy에 추가
Project의 Standard Assets > Vehicles > Prefabs > Car를 Hierarchy에 추가합니다.

Main Camera를 Car의 자식 요소로 만들기
Scene의 Main Camera를 Car 아래로 드래그 앤 드롭합니다.

Main Camera의 transform 조정
카메라를 차가 조작하기 쉬운 위치와 각도에 기호로 조정합니다.

무대 만들기
차를 달리기 위한 무대를 만듭니다.

여기에서는 Simple Home Stuff 이라는 자산을 빌려 스테이지로 이용했습니다.
차와 스테이지의 사이즈감을 맞추기 위해, Car의 Scale을 0.25로 설정하고 있습니다.
Oculus Go 컨트롤러에서 작동 가능
Car 조립식에 부착된 CarUserController.cs
를 삭제하고 새 CarMovementController.cs
를 만들고 연결합니다.
여기에서는 컨트롤러의 터치패드에 가속과 방향전환, 트리거에 브레이크(백)를 할당하고 있습니다.
using UnityEngine;
using UnityStandardAssets.Vehicles.Car;
[RequireComponent(typeof (CarController))]
public class CarMovementController : MonoBehaviour
{
private CarController m_Car;
private void Awake()
{
m_Car = GetComponent<CarController>();
}
private float h;
private float v;
private void Update()
{
OVRInput.Update();
// タッチパッドを触っている座標を元に進む方向を決める
Vector2 touchVec = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad);
h += touchVec.x * 0.1f * Time.deltaTime;
// タッチパッドを押していたらアクセル
if(OVRInput.Get(OVRInput.Button.One))
{
v += 0.1f * Time.deltaTime;
}
// トリガーを押していたらブレーキ
else if (OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger))
{
v -= 0.1f * Time.deltaTime;
}
else
{
v = 0f;
}
}
private void FixedUpdate()
{
OVRInput.FixedUpdate();
m_Car.Move(h, v, v, 0f);
}
}
레츠 빌드!
Oculus Go 드라이브 #OculusGo #OculusGoDev 피 c. 라고 r. 코 m/pBL9yT주 Fs — m4tcha (@_m4tcha) June 16, 2018
Reference
이 문제에 관하여(Oculus Go로 바삭 바삭한 차), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/kiepng/items/5d9fe340e02ec70ee91a
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
using UnityEngine;
using UnityStandardAssets.Vehicles.Car;
[RequireComponent(typeof (CarController))]
public class CarMovementController : MonoBehaviour
{
private CarController m_Car;
private void Awake()
{
m_Car = GetComponent<CarController>();
}
private float h;
private float v;
private void Update()
{
OVRInput.Update();
// タッチパッドを触っている座標を元に進む方向を決める
Vector2 touchVec = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad);
h += touchVec.x * 0.1f * Time.deltaTime;
// タッチパッドを押していたらアクセル
if(OVRInput.Get(OVRInput.Button.One))
{
v += 0.1f * Time.deltaTime;
}
// トリガーを押していたらブレーキ
else if (OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger))
{
v -= 0.1f * Time.deltaTime;
}
else
{
v = 0f;
}
}
private void FixedUpdate()
{
OVRInput.FixedUpdate();
m_Car.Move(h, v, v, 0f);
}
}
Reference
이 문제에 관하여(Oculus Go로 바삭 바삭한 차), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kiepng/items/5d9fe340e02ec70ee91a텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)