Transform.TransformDirection 变换方向
function TransformDirection (direction : Vector3) : Vector3
Description描述
Transforms direction from local space to world space.
![](https://img-blog.csdn.net/20141030101836580)
function TransformDirection (direction : Vector3) : Vector3
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.
上面的取自Unity3d圣典
注意下面两个例子中的相机(相机需要加rigidbody去掉重力)移动的区别:
例1:
public Transform cam;
public Vector3 cameraRelativeRight;
void Start () {
cam = Camera.main.transform;
rigidbody.AddForce (Vector3.right*1000);}
相机参数变化情况:
例2:
public Transform cam;
public Vector3 cameraRelativeRight;
void Start () {
cam = Camera.main.transform;
cameraRelativeRight = cam.TransformDirection(Vector3.right);//转变变换
rigidbody.AddForce (cameraRelativeRight*1000);}
完毕。
欢迎各位不吝赐教!