Quaternion.operator * 运算符 乘法

static operator * (lhs : Quaternion, rhs : Quaternion) : Quaternion

Description描述

Combines rotations lhs and rhs.

组合旋转lhs和rhs。

Rotating a point first with lhs and then with rhs is the same as rotating the point by the combined rotation. Note that rotations are not commutative: lhs * rhs does not equal to rhs * lhs.

旋转一个点,首先用lhs,然后用rhs旋转,与使用组合旋转相同。注意旋转不可交换: lhs*rhs不等于rhs*lhs.

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Transform extraRotation;
	public void Awake() {
		transform.rotation *= extraRotation.rotation;
	}
}
// Applies the rotation of
// extraRotation to the current rotation
//应用extraRotation的旋转给当前旋转
var extraRotation : Transform;
transform.rotation *= extraRotation.rotation;

• static operator * (rotation : Quaternion, point : Vector3) : Vector3

Description描述

Rotates the point point with rotation.

用rotation旋转point点。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Vector3 relativeDirection = Vector3.forward;
	void Update() {
		Vector3 absoluteDirection = transform.rotation * relativeDirection;
		transform.position += absoluteDirection * Time.deltaTime;
	}
}
// Moves the object along relativeDirection
// Usually you would use transform.Move for this
//沿着relativeDirection移动物体
//通常你应该使用transform.Move移动
var relativeDirection = Vector3.forward;

function Update () {
	var absoluteDirection = transform.rotation * relativeDirection;
	transform.position += absoluteDirection * Time.deltaTime;
}
最后修改:2011年1月16日 Sunday 16:03

本脚本参考基于Unity 3.4.1f5

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