public static Vector3D FindFreePos(BoundingSphereD gate, float sphereradius) { Random rand = new Random(); MyEntity safezone = null; var entities = MyEntities.GetEntitiesInSphere(ref gate); foreach (MyEntity myentity in entities) { if (myentity is MySafeZone) { safezone = myentity; } } return((Vector3D)MyEntities.FindFreePlaceCustom(gate.RandomToUniformPointInSphere(rand.NextDouble(), rand.NextDouble(), rand.NextDouble()), sphereradius, 20, 5, 1, 0, safezone)); }