Unity中transform.TransformDirection()的用法(转载)

下面给大家介绍的是Unity中Transform.TransformDirection作用,想知道的可以看看。

Transform.TransformDirection 变换方向

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有同样的长度。

实例说明:

Unity中transform.TransformDirection()的用法(转载)

m_cube是一个沿着X轴旋转了90度的方块。

Unity中transform.TransformDirection()的用法(转载)
方块沿着自身的z轴移动

m_cube.transform.Translate(Vector3.forward)

【Unity】 Transform.TransformDirection作用

方块沿着世界的z轴移动

m_cube.transform.Translate(m_cube.transform.TransformDirection(Vector3.forward) );

【Unity】 Transform.TransformDirection作用

原文链接

著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。