[Solved] Detecting objects with OverlapSphere within the frame they are created?

Hey,

I’ve been trying to procedurally generate several "road segments“ with obstacles at random positions on top of the segments.
This has to be done when the scene loads.
So my approach was, to solve this with a while-loop inside the Start() method and check for overlaps with Physics.OverlapSphere.
I ran into the problem, that Physics.OverlapSphere returns either no object at all or every object on a specific segment when setting the radius very high.
After several different attempts in solving this issue, I thought that maybe this has to do with the fact, that everything happens within one singular frame.
I already found this post to a similar problem:

Does this also apply to Physics.OverlapSphere? If so, are there ways to solve this differently?

I hope, someone can help me with this!

Thanks

My Code:
(Simplified, because the functionality is split across several scripts)

   void Start()
   {
    while (attempts < maxObjects) 
     {
      PlaceObstacleOnRoad(obstacle, segment);
      attempts++;
      }
   }
   void PlaceObstacleOnRoad(GameObject obstacle, GameObject segment)
        {
            Collider segmentcol = segment.GetComponent<Collider>();
            Collider obstaclecol = obstacle.GetComponent<Collider>();
        
            //Get Range of Possible Positions on Segment
        
            float placementZMax =  0.5f - (obstaclecol.bounds.extents.z / segment.transform.localScale.z); 
           //Local Position Max

           float placementZMin = -0.5f + (obstaclecol.bounds.extents.z / segment.transform.localScale.z); 
           //Local Position Min
        
            float placementZPosition = Random.Range(placementZMin, placementZMax);
            Vector3 placementPosition = new Vector3(obstaclecol.bounds.size.x, 0f, placementZPosition);
        
            Collider[] overlaps;
        
      overlaps = Physics.OverlapSphere(segment.transform.TransformPoint(placementPosition), radius);
                    
            if (overlaps.Length < 1)
                { 
                   //Spawn Code Here
                }
}

I solved it by turning the function wrapping the while-loop into a coroutine and using WaitForFixedUpdate().