Unity does not update fast enough

I have the following code in C#:

transform.position = newMarblePos;
Collider[] marbles = Physics.OverlapSphere(newMarblePos, 0.1f);
Debug.Log (marbles.Length ) ;

This prints out 0. This does not make any sense: clearly the GameObject should show up in the intersection. Why is this the case? Could it be that by the time of my Debug.Log statement, Unity has not updated the transform yet? Does Unity not wait for a statement to finish before executing the next one? Regardless, any insight into the cause of this bug and how to work around it would be greatly appreciated.

The position is updated immediately. The overlapsphere is a part of the physics engine, though, and the physics engine updates in the FixedUpdate step. So the overlapsphere won’t find the original marbe before at least one FixedUpdate has run.

If you want to guarantee that the overlapsphere finds the original marble, put everything in a coroutine, and use WaitForFixedUpdate to wait until the colliders has updated.