轉自:http://blog.csdn.net/neil3d/article/details/50767947html
這兩個終於搞了一套Gear VR,開始嘗試了一下使用虛幻4開發Gear VR遊戲。這裏把開發上手的過程作一個筆記和你們分享。app
首先是設置開發環境,總體上跟着官方文檔走就行了:
https://docs.unrealengine.com/latest/INT/Platforms/GearVR/Prerequisites/index.htmlide
其中重點的步驟記錄以下。函數
設置手機,開啓USB Debug
- 打開手機的「設置」->關於手機:連續點擊「版本號」一欄;
- 上述操做成功以後,系統設置中會出現「開發者選項」;
- 進入「開發者選項」,開啓「USB 調試」。
設置Gear VR Service爲開發者模式
這一步很是重要,不然APK上傳以後沒法啓動,會提示:請插入Gear VR設備。
具體步驟參見:
首先,要上傳一個帶有osig文件的App,不然你會獲得一個報錯:You are not a developer
- Go to Settings > Application Manager
- Select Gear VR Service
- Select Manage Storage
- Click on VR Service Version several times until the Developer Mode toggle shows up
- Toggle Developer Mode
配置Oculus簽名文件(osig)
- 手機使用USB線鏈接電腦;
- 使用「adb devices」獲取 Device ID,例如:0915f92985160b05
- 打開網址:https://developer.oculus.com/osig/
- 把簽名的Device ID粘貼進輸入框,而後點Download按鈕;
- 將獲取到的文件(例如oculussig_0915f92985160b05)放入:引擎安裝目錄\引擎版本號\Engine\Build\Android\Java\assets,例如:
虛幻4 Project
- 只能使用C++項目模板,不能使用Blueprint項目模板;(官方的視頻裏說的,他用的是4.7)
- 設置Project Settings:
- Android
- Minimum SDK Version: 19
- Configure the AndroidManifest for deployment to GearVR [check]
設置好以後,從Unreal Editor中Launch到手機,或者Package Android,均可以正常啓動遊戲。
VR經常使用操做接口
UE4在Blueprint中提供了一組HMD函數,以下圖所示:
另外,對於Gear VR,能夠開啓Oculus Library插件,訪問下圖中的函數:
經常使用功能實現
Gear VR頭盔右側有一個Touchpad,經試驗,能夠經過Blueprint中的Touch事件來響應其操做,例如:
另外,目前VR中經常使用的就是視點交互的方式,須要使用Line of Sight檢測,例如: