Created
June 27, 2018 09:29
-
-
Save todorok1/90c9847b2387cacb30dff76f512a6e1e to your computer and use it in GitHub Desktop.
球体内に小さなオブジェクトをランダムにインスタンス化する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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