本文适合有一定Unity/UE开发经验的开发者阅读,
准备环境:
1. Steam & SteamVR(成为开发者)
2. UE4.8+(本文采用UE4.10.1)
3. Visual Studio 2013/2015
在VIVE上VR预览
1. 首先要保证SteamVR Status连接都是正常的。
https://developer.htcvive.com/cn/data/attachment/forum/201601/29/141913jfsnsnkh7hi55hn6.jpg
2. 建立新的工程,C++/Blueprint都可以,关键在于
No Starter Content
https://developer.htcvive.com/cn/data/attachment/forum/201601/29/142153r6hicqtcqczhhhh6.jpg
3. 等待工程建立完成初步编译成功后,就可以预览默认的场景了。
Play -> VR Preview
https://developer.htcvive.com/cn/data/attachment/forum/201601/29/142013ysggmzqjwsqcucjj.jpg
美化场景
1. 引入Starter Content资源包
https://developer.htcvive.com/cn/data/attachment/forum/201601/29/141955os2wvqvut0vwgzxw.jpg
2. 这里会做一个场景,玩家站在海洋中漂浮的木板上,可以体会VIVE的沉浸感。
Floor的Materials为导入的资源中的M_Water_Ocean
Boat的Materials为导入资源中的M_Wood_oak
3. 为了增强Boat的真是感觉,随机加入了根据水波摇晃的代码。
https://developer.htcvive.com/cn/data/attachment/forum/201601/29/142020g0qo0yjo00nt0fo5.jpg
Boat继承自AStaticMeshActor
重载 virtual void Tick(float DeltaTime) override;在其中最终通过SetActorRotation()来实现摇晃的功能。
这里不要忘了把Mobility设置为 Movable,或者在代码中通过SetMobility(EComponentMobility::Movable);来控制。
4. Play一下,有点感觉了吧。
加入Controller
虽然有了场景,但是因为没有把玩家的位置放在木板上,还有看不到Controller所以沉浸感还是没有,下面逐一实现。
1. 这里需要对VR做Word Settings, 做一个VR版本的GameMode, ,具体可以通过学习Epic官方的教程。https://docs.unrealengine.com/latest/INT/Platforms/SteamVR/QuickStart/2/index.html
2. 设置完成后,Player Start要放在Boat上。
3. 这里要加入Controller,但是官方教程中是用的Leap Motion为例,在VIVE中需要使用Motion Controllerhttps://docs.unrealengine.com/latest/INT/Platforms/VR/MotionController/index.html
4. 其中建立的VR_Pawn的组件图如下,这里左右手的StaticMesh随你喜欢,手枪、火箭炮都可以,但是注意Rotation要调整好
https://developer.htcvive.com/cn/data/attachment/forum/201601/29/142036q4cjyhy7hxjxg05x.jpg
https://developer.htcvive.com/cn/data/attachment/forum/201601/29/142026n3a2662szaarlyxu.jpg
5. 这些都编译通过后,再检查下GameMode
https://developer.htcvive.com/cn/data/attachment/forum/201601/29/142032r002nhrb09y9hh98.jpg
Let’s VIVE
点击运行,你是不是发现自己站在了一望无际的大海中的一块孤零零的木板上!
发挥你的想象让我们一起来 VIVE !