ドキュメント

Unity Engine

Unity Engine

rotation

Returns a random rotation (Read Only).
読み終わるまでの所要時間 1 分最終更新 1ヶ月前

Definition

  • Type: Property
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
public static Quaternion rotation { get; }

Remarks

Randomize the
x
,
y
,
z
, and
w
of a Quaternion each to [-1.0..1.0] (inclusive) via Random.Range and normalize the result. See also Random.rotationUniform for a slower but higher quality algorithm.

Examples

using UnityEngine;// Click the "Rotate!" button and a rotation will be appliedpublic class ExampleClass : MonoBehaviour{ void OnGUI() { if (GUI.Button(new Rect(10, 10, 100, 50), "Rotate!")) { transform.rotation = Random.rotation; } }}