Transform.TransformDirection 变换方向
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.
这个操作不会受到变换的缩放和位置的影响。返回的向量与direction有同样的长度。
实例说明:
m_cube是一个沿着X轴旋转了90度的方块。
方块沿着自身的z轴移动
m_cube.transform.Translate(Vector3.forward)
方块沿着世界的z轴移动
m_cube.transform.Translate(m_cube.transform.TransformDirection(Vector3.forward) );
转自:http://blog.youkuaiyun.com/dreamsnow127/article/details/39854645
本文详细介绍了Unity中TransformDirection函数的使用方法,该函数用于将局部空间中的方向转换到世界空间,并保持方向向量的长度不变。通过示例对比了Translate函数结合TransformDirection与不结合该函数时的区别。
638

被折叠的 条评论
为什么被折叠?



