# Quaternion.operator * 运算符 乘法

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

Description描述

Combines rotations lhs and 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.

``````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.

``````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;
}``````
Page last updated: 2011-1-16