在看这节之前,请先观看我之前的课程:
[GVR]Google VR 和Gear VR app设定生成
如果觉得我的课程有用请给个赞和喜欢吧,谢谢!
上一节我们可以通过鼠标和键盘按钮观操纵我们视觉行走

这一节的目标,我们是在深林中约会漫步了
1.首先我们在AssetStore里面找到一个免费的森林资源

2.我们打开森林的目录

点开demoScene_free
删除 FirstPersonController和Main Camera

3.添加GVR的资源
4.添加GVRMain

移动一下摄像头到森林里面

5.添加VRLookWalk的C#文件到GvrMain

代码编写

解析一下代码
toggleAngle 是x轴的角度为30
speed行走速度
moveForward是否行走
CharcterController是角色控制器,详细解析在 [GVR]Google VR 行走控制 里面
GVRHead是Gvr头部对象,可以看作为人类的头部,之前的课程也有解析过[GVR]Google VR 焦点事件触发
Start函数里面是初始化CharcterController和GVRHead 两个对象
Update函数里面的解析
当头部的垂直方向角度大于30度且小于90度,设定为行走
simpleMove就行行走的调用了,详细解析在[GVR]Google VR 行走控制里面
做完这些之后,别漏了要在GvrMain上添加CharcterController的对象

7 这样就可以在森林里愉快的漫步了

这节的课程就到这里了
那么下一次的课程我们将会教大家如何Google VR如何使用按钮操作和FPS操纵
敬请期待吧!
网友评论