Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Random.rotationUniform

static var rotationUniform: Quaternion;
static Quaternion rotationUniform;
static rotationUniform as Quaternion

Description

Returns a random rotation with uniform distribution (Read Only).

// Sets a random orientation for the object.
transform.rotation = Random.rotationUniform;
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Example() {
        transform.rotation = Random.rotationUniform;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Example() as void:
		transform.rotation = Random.rotationUniform