Raycast doesn't hit instantiated object within same frame of instantiation.
I have code that generates and instantiates a level using a grid. The code waits until every grid square is finished and ready. Then my A* Pathfinding shoots raycasts down to the grid and detects what is walkable ground and what are obstacles. This works fine for premade levels but with generated levels, it seems as though the raycast is being fired before the instantiated ground. which doesn't make sense since my code waits for everything to be instantiated and then fires the raycast. I tested by waiting 3 seconds more using an IEnumerator and then all of a sudden it works. I removed the IEnumerator and tested some more and I noticed the raycast detects only the first part of the instantiated ground.
So this goes against everything I have read online that an object is instantiated as soon as the instantiate line of code finishes since a later called raycast is shooting off before the instantiated object has instantiated. So how can I wait for when the object has ACTUALLY finished instantiating? Is this a case of the object being instantiated but not rendered yet so the raycast is just passing through?