一.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