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.

此操作不受缩放影响。

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.

此操作不受缩放影响。

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);
最后修改:2010年12月19日 Sunday 16:00

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。