Transform
- childCount
- DetachChildren
- eulerAngles
- Find
- forward
- InverseTransformDirection
- InverseTransformPoint
- IsChildOf
- localEulerAngles
- localPosition
- localRotation
- localScale
- localToWorldMatrix
- LookAt
- lossyScale
- parent
- position
- right
- root
- RotateAround
- Rotate
- rotation
- TransformDirection
- TransformPoint
- Translate
- up
- worldToLocalMatrix
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有同样的长度。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Transform cam = Camera.main.transform;
public Vector3 cameraRelativeRight = cam.TransformDirection(Vector3.right);
public void Awake() {
rigidbody.AddForce(cameraRelativeRight * 10);
}
}
// Calculate the x-axis relative to the camera
//相对于摄像机计算x轴
var cam : Transform = Camera.main.transform;
var cameraRelativeRight : Vector3 = cam.TransformDirection (Vector3.right);
// Apply a force relative to the camera's x-axis
//相对于摄像机的x轴,应用一个力。
rigidbody.AddForce (cameraRelativeRight * 10);
• function TransformDirection (x : float, y : float, z : float) : Vector3
Description描述
Transforms direction x, y, z from local space to world space.
变换方向x, y, z从自身坐标到世界坐标。
This operation is not affected by scale or position of the transform. The returned vector has the same length as direction.
这个操作不会受到变换的缩放和位置的影响。返回的向量与direction有同样的长度。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Transform cam = Camera.main.transform;
public Vector3 cameraRelativeRight = cam.TransformDirection(1, 0, 0);
public void Awake() {
rigidbody.AddForce(cameraRelativeRight * 10);
}
}
// Calculate the x-axis relative to the camera
//相对于摄像机计算x轴
var cam : Transform = Camera.main.transform;
var cameraRelativeRight : Vector3 = cam.TransformDirection (1, 0, 0);
// Apply a force relative to the camera's x-axis
//相对于摄像机的x轴,应用一个力。
rigidbody.AddForce (cameraRelativeRight * 10);
最后修改:2010年12月19日 Sunday 15:49