1、Transform
常用的方法:
1)LookAt(): 調整對象的z軸指向目標對象的中心
2)Rotate(): 旋轉對象的角度
3)RotateAround(): 以某一點爲中心,沿着指定的軸旋轉。
4)TransformDirection(): 將自身座標裝換成世界座標。
例子:
假如,當前狀態下,對象自身與世界座標的夾角是(0,-30, 0).
Vector3 direction = transform.TransformDirection(Vector3.forword);
等同於:
Quaternion rotation = Quaternion.Euler(0, -30, 0);
Vector3 direction = rotation * Vector3.forward;
5)Translate(): 用於對象的平移
2、Time
1、timeScale。類似於時間的流動速度設置。如果,設置爲零,時間靜止。1爲正常的時間流動速度。
2、time。從遊戲開始運行,到當前幀的總時間。
3、timeSinceLevelLoad。在該Scene中,從開始到當前經歷的時間。
4、deltaTime。 上一幀執行的時間(兩幀開始之間的間隔)
5、fixedDeltaTime. 物理更新時間,在Edit->Project setting->Time中可設置,默認爲0.02秒。
6、realtimeSinceStartup。等於 Time.time/timeScale.
3、Vector3
1、Lerp(Vector3 from, Vector3 to, float fraction):
這個函數的意思是:在from和to兩點之間,以線性的方式插入一個值,而這個值的大小取決於比例fraction(0~1)的大小。舉個例子:
Vector3 middle = Vector3.Lerp(new Vector3(0,0,1), new Vector3(0,0,8), 0.1);
那麼 middle的值就是 Vector3(0,0, 1.7);
middle = [(0,0,8) - (0,0,1)]*0.1;
2、Slerp(Vector3 from, Vector3 to, float t):
這個函數和Lerp函數功能類似,但是,在這個函數裏,它將from和to看做兩個向量,使用的是曲線插值,當然,插值的大小還是取決於 t 變量。