Hi everyone. I wanted to randomize where my powerups will appear on a spherical world and wasnt sure how should i approach it ?
i want it to appear on the ground at randomy locations. I figure some kind of raycast is required but how do i randomize the x.y.z position to start, and how do i get the direction i want to raycast (to ensure it always intersects with the spherical planet.
Also how do i randomize when it spawns. for example sometimes a powerup might spawn every 5 seconds. other times it might spawn every 10 seconds.
I don’t think anyone here is going to write the script for you. But start here:
Random.Range will gave you a random number between a defined number range.
Look into the “Mesh” class, I think .vertices will return a vector3 for your vertices you can place into an array and then count the number of vertices on the mesh with .vertexCount and store that into a variable that runs through a Random.Range.
In theory this should give a random vertex on the sphere mesh, the vector3 of that vertex and then you can spawn your item. It will be random every time and the time between spawns will also be random.
Good Luck.