Hi everyone, I’m brand new to Unity and trying to implement a simple program. My goal is to make an app for the Hololens that I could send 3D coordinate points into, and have them show up as spheres at those points. Is this possible to do, and how would I go about it?
In other words, I want to be able to have a random number generator generate random (x,y,z) coordinates every 1 second, and have it show up as small spheres at the generated coordinates.
Yeah, you can surley do this.
You could create a mesh by code, but if you just want to put spheres in your level, it’s easier to:
-Make a sphere in your scene [in the hierarchy RMB>3D Object>Shpere] or import one form a 3D app.
-Convert it to a prefab [grub your shpere in the hierarchy and drag it to your project folder].
-Delete the sphere in te hierarchy.
-Do a script that has something like this:
public Transform prefab; //in the inspector hook the prefab of the sphere here.
void Update() {
yourVector = new Vector3(Random.Range(0,100), Random.Range(0,100), Random.Range(0,100)); //or if you want an actual position, just set the coordinates for xyz here.
Instantiate(prefab, yourVector, Quaternion.identity); //This instanciates your prefab at the position set by the vector
}