Last active
August 29, 2015 14:06
-
-
Save rbreve/e1294661c2054adbcde3 to your computer and use it in GitHub Desktop.
Placing objects around a sphere in Unity3D
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
// sphere radius | |
float r= 5f; | |
Vector3 randomPosition = Random.onUnitSphere*r; | |
GameObject o = Instantiate(item, randomPosition, Quaternion.identity ) as GameObject; | |
Vector3 up = randomPosition; | |
Vector3 LookAt = Vector3.Cross(up, -transform.right) + up; | |
o.transform.LookAt(LookAt, up); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment