官方描述:
JavaScript
⇒ TransformDirection(direction: Vector3): Vector3; C#
⇒ Vector3 TransformDirection(Vector3 direction);
Description 描述
Transforms direction from local space to world space.
變換方向從局部坐標轉換到世界坐標。
This operation is not affected by scale or position of the transform. The returned vector has the same length as direction.
這個操作不會受到變換的縮放和位置的影響。返回的向量與direction有同樣的長度。
個人理解:
如自身Z軸方向跟世界Z軸方向一致,目前我的位置是(0,0,0),我向前(相對自身)移動一個單位,我的位置變成(0,0,1),
即為:transform.postion += vector3(0,0,1);
當自身Z軸方向跟世界X軸方向一致時,我的位置還是(0,0,0),我向前(相對自身)移動一個單位,我的位置變成(1,0,0),
即為:transform.postion += transform.TransformDirection(vector3(0,0,1))的結果。