Quaternion.FromToRotation 从from到to旋转
static function FromToRotation (fromDirection : Vector3, toDirection : Vector3) : Quaternion
Description描述
Creates a rotation which rotates from fromDirection to toDirection.
从fromDirection到toDirection创建一个旋转。
Usually you use this to rotate a transform so that one of its axes eg. the y-axis - follows a target direction toDirection in world space.
通常你使用这个旋转一个变换的其中一个轴,例如,在世界空间,y轴跟随一个目标方向toDirection。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public void Awake() {
transform.rotation = Quaternion.FromToRotation(Vector3.up, transform.forward);
}
}
// Sets the rotation so that the transform's y-axis goes along the z-axis
//设置旋转,变换的y轴转向z轴
transform.rotation = Quaternion.FromToRotation (Vector3.up, transform.forward);
最后修改:2011年1月16日 Sunday 16:39