Question by
Flopado · Jan 24, 2016 at 06:17 PM ·
c#scripting probleminstantiatesphere
Instantiate a Prefab along the surface of a sphere. C#
I'm trying to instantiate a prefab along the surface of a sphere, but I don't know what am I supposed to do. It should be like that:
I was looking for it on the internet, but I found only JS scripts.
asdadasd.png
(8.7 kB)
Comment
That's pretty vague. How do you want to place it there? How is the sphere created? Do you want it to be random?
public Vector2 PlaceAlongCircle() {
Vector2 circleCenter = new Vector2(14f, 32.3f);
float radius = 5f;
Vector2 rand = Random.insideUnitCircle * radius;
return circleCenter + rand;
}
I haven't tested this but i think it would work. http://docs.unity3d.com/ScriptReference/Random-insideUnitCircle.html