Hi!

Ive been working on this game, where i want to have a minimap where i can scan the 3d environment periodically. (code below)

To do this i cast rays out of the player, and if they collide i instance a sphere prefab.

The problem is that i used to do that just in a circle around the player, which needed around 360 prefabs to look good. Now with a sphere, i need a minimum of 3600… and it lags every time i generate them.

I have tried creating simple triangle polygons, as i thought it would lag less, but it didnt really help. Maybe i did something wrong?

If anyone has any ideas of what i could do to improve this id really appreciate it!!!

Thanks in advance ^^

```
public class areaScan : MonoBehaviour
{
[SerializeField] GameObject prefab;
[SerializeField] int rayCount;
[SerializeField] float sphereRadius;
[SerializeField] LayerMask layerMask;
void Update()
{
if (Input.GetKeyDown(KeyCode.Q))
{
for (int i = 0; i < rayCount; i++)
{
float inclination = Mathf.Acos(1 - 2f * i / rayCount);
float azimuth = Mathf.PI * (1 + Mathf.Sqrt(5)) * i;
float x = Mathf.Sin(inclination) * Mathf.Cos(azimuth);
float y = Mathf.Sin(inclination) * Mathf.Sin(azimuth);
float z = Mathf.Cos(inclination);
Vector3 direction = new Vector3(x, y, z);
RaycastHit hit;
if (Physics.Raycast(transform.position, direction, out hit, sphereRadius, layerMask))
{
Instantiate(prefab, hit.point, Quaternion.identity);
}
}
}
}
}
```

Unity view when generating spheres: