vr 第三次学习 第一个小应用

一.Tutorial: Build Your First VR App(第一个vr应用)

1.创建项目 New->Create Project

2.Save Scene as 保存场景到。

3.3D Object > Plane 创建地板   (reset)

重命名。

4.创建第一面墙,3D Object > Cube  

Scale        x->10       ,position     y->0.5      ,改名。

5.移动墙到z   -   5;

6.创建第二面墙,   z   -   5;   rename

7.创建第三面墙,rotation,旋转90度。

8.创建第四面墙,继续保持对于原点的对称。

9.创建player玩家,3D Object > Sphere     position。0,0.5,0

10.移动camera。保证球体会被看到。

二。脚本

1.添加刚体

2.添加脚本组件。

using System.Collections;
            using System.Collections.Generic;
            using UnityEngine;
            
            public class PlayerController : MonoBehaviour {
            public int speed = 0;
            
            // Use this for initialization
            void Start () {
            
            }
            
            // Update is called once per frame
            void Update () {
            
            // get input data from keyboard or controller
            float moveHorizontal = Input.GetAxis("Horizontal");
            float moveVertical = Input.GetAxis("Vertical");
            
            // update player position based on input
            Vector3 position = transform.position;
            position.x += moveHorizontal * speed * Time.deltaTime;
            position.z += moveVertical * speed * Time.deltaTime;
            transform.position = position;
            
            }
            }

三.Modify your project for VR

1.Edit - Project Settings  >  Player

2.Other Settings > Rendering



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章