Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
球体内に小さなオブジェクトをランダムにインスタンス化する
void InstantiateSmallCubeInSphere(){
for (int i = 1; i <= batchNum; i++){
Vector3 position = Random.insideUnitSphere;
position.x *= cubeSize.x / 2f;
position.y *= cubeSize.y / 2f;
position.z *= cubeSize.z / 2f;
position += offset;
// Prefabをインスタンス化する
GameObject obj = Instantiate(cubePrefab, position, Quaternion.identity);
obj.transform.SetParent(gameObject.transform);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.