安装Unity

时请勾选VR support插件

 

先了解一下快捷键

Unity VR的Hello World!

https://unity3d.com/cn/learn/tutorials/topics/xr/getting-started-vr-development

 

你需要Standard Assets

而且这些东西并不会跟随软件默认安装(自从2017年开始),所以你需要额外下载(仍然免费)

https://www.assetstore.unity3d.com/en/?stay#!/content/32351

 

了解一下如何创建Prefebs

你所做的大部分重复出现的模型都需要是Prefebs

https://docs.unity3d.com/2018.3/Documentation/Manual/CreatingPrefabs.html

 

当游戏开始时执行一个脚本

何种函数叫做Awake()和Start()

https://unity3d.com/cn/learn/tutorials/topics/scripting/awake-and-start

 

你不会连脚本(script)是什么都不知道吧?

https://docs.unity3d.com/Manual/CreatingAndUsingScripts.html

 

EX:我想在空间里随机摆方块

那你可以查看一下这个完整的例子分析:

https://catlikecoding.com/unity/tutorials/object-management/persisting-objects/

 

拥有真实物理属性的物体

通常指的是刚体(rigidbody)

https://docs.unity3d.com/Manual/class-PhysicsManager.html

 

RaycastHit

raycast会负责判断一条ray是否hit了某项物体,如果hit了,就返回一个raycastHit。相当于一个reference。

https://docs.unity3d.com/530/Documentation/ScriptReference/RaycastHit.html

一个使用例子:

https://answers.unity.com/questions/143480/raycasthit-explanation-wanted.html

 

几种新建Ray的方法

Ray(Vector3 originVector3 direction);

这个是最基本的constructor。

 

Camera.ViewportPointToRay(float x, float y, float z);

获得一条从摄像头发出,去往一个屏幕二维屏幕上的点的Ray。其中左下角是(0,0,0),右上角是(1,1,0),Z轴是被忽略的信息。

e.g.,the object camera is directly looking at is (0.5,0.5,0)

https://docs.unity3d.com/ScriptReference/Camera.ViewportPointToRay.html

 

如何计算两个Ray之间的夹角?

只要计算他们的direction vec3的夹角就行了

float angel = Vector3.Angle(ray.direction, ray2.direction);

RaycastHit的物体如何变色?

hit.transform.gameObject.GetComponent< Renderer > ().material.color = Color.red;

 

Unity的数组

https://docs.unity3d.com/ScriptReference/Array.html

 

Find object by Tags

https://docs.unity3d.com/ScriptReference/GameObject.FindGameObjectsWithTag.html

 

如何计时

Time.deltatime();

The completion time in seconds since the last frame (Read Only).

https://docs.unity3d.com/ScriptReference/Time-deltaTime.html