I have a sphere. I want to hit it in random locations on the surface, and then mark each hit with a cube (to be replaced with an actual art asset later, obviously). How do I do this? I'm not having much luck, as my raycast-fu is weak. Here are the relevant bits of a script that's attached to the sphere:
var currentRuinsNumber = 0;
var randomRuinsVector : Vector3;
// Find places for ruins
while (currentRuinsNumber < numberOfRuins)
{
randomVector = Vector3(Random.Range(-1.0, 1.1), Random.Range(-1.0, 1.1), Random.Range(-1.0, 1.1) );
var ray : Ray = Ray(Vector3.zero, randomRuinsVector);
var hit : RaycastHit;
if (collider.Raycast(ray, hit, 100.0))
{
Debug.DrawLine (ray.origin, hit.point);
// put a cube here
}
currentRuinsNumber++;
}