I’m using the script segment near the bottom of this question in order to instantiate and position prefabs in a torus shaped area to make a asteroid belt. The problem I’ve run into is I can’t set the height of the tube or the width of the tube separately, it uses the shared radius. Anyhow, here is the code, see if you can find the solution where I couldn’t. Thanks
Vector3 RandInTorus() {
Vector3 dir = Vector3.up * ringMidlineRadius;
dir = Quaternion.AngleAxis (Random.Range (0.0f, 360.0f), Vector3.forward) * dir;
Vector3 axis = Vector3.Cross (dir, Vector3.forward);
Vector3 dir2 = dir.normalized * Random.Range (0.0f, tubeRadius);
dir2 = Quaternion.AngleAxis (Random.Range (0.0f, 360.0f), axis) * dir2;
return transform.TransformPoint (dir + dir2);
}