Transform.InverseTransformDirection 变换反方向
function InverseTransformDirection (direction : Vector3) : Vector3
Description描述
Transforms a direction from world space to local space. The opposite of Transform.TransformDirection.
变换方向从世界坐标到自身坐标。和Transform.TransformDirection相反。
This operation is unaffected by scale.
此操作不受缩放影响。
C#
JavaScript
using UnityEngine;using System.Collections;public class example : MonoBehaviour {private Vector3 relative;public void Awake() {relative = transform.InverseTransformDirection(Vector3.forward);Debug.Log(relative);}}
// transform the world forward into local space://变换世界向前坐标变为自身坐标private var relative : Vector3;relative = transform.InverseTransformDirection(Vector3.forward);Debug.Log(relative);
• function InverseTransformDirection (x : float, y : float, z : float) : Vector3
Description描述
Transforms the direction x, y, z from world space to local space. The opposite of Transform.TransformDirection.
变换方向x, y, z 从世界坐标到自身坐标,和Transform.TransformDirection相反。
This operation is unaffected by scale.
此操作不受缩放影响。
C#
JavaScript
using UnityEngine;using System.Collections;public class example : MonoBehaviour {private Vector3 relative;public void Awake() {relative = transform.InverseTransformDirection(0, 0, 1);Debug.Log(relative);}}
// transform the world forward into local space://变换世界向前坐标变为自身坐标private var relative : Vector3;relative = transform.InverseTransformDirection(0, 0, 1);Debug.Log(relative);