Version: 2020.1

Random.onUnitSphere

切换到手册
public static Vector3 onUnitSphere ;

描述

返回半径为 1 的球体表面上的随机点(只读)。

using UnityEngine;

public class Example : MonoBehaviour { void Start() { // Sets the rigidbody velocity to 10 and in a random direction.

GetComponent<Rigidbody>().velocity = Random.onUnitSphere * 10; } }