Version: 2023.2
public static float Angle (Quaternion a, Quaternion b);

描述

Returns the angle in degrees between two rotations a and b. The resulting angle ranges from 0 to 180.

示例:请考虑两个 GameObject(A 和 B)围绕第三个 GameObject (C) 移动的情况。从 C 到 A 和从 C 到 B 的线构成一个随时间变化的三角形。CA 和 CB 之间的角度为 Quaternion.Angle 提供的值。

using UnityEngine;
using System.Collections;

// Calculates the angle (degrees) between // the rotation of this transform and target.

public class ExampleClass : MonoBehaviour { public Transform target;

void Update() { float angle = Quaternion.Angle(transform.rotation, target.rotation); } }