Hi I’m calling a coroutine from a function and waiting for FixedUpdate to happen. If I remember correctly(I can’t exactly be sure) this used to be ok too but it’s not working now.
public void CreateMap()
{
RenewGamePhysics = false;
StartCoroutine(Generate());
}
private IEnumerator Generate()
{
//Spawn objects with colliders
//start waiting for physics to be updated
RenewGamePhysics = true;
PhysicsUpdated = false;
int iter = 0;
while (!PhysicsUpdated && iter < 100)
{
iter++;
yield return null;
}
if (!PhysicsUpdated)
{
Debug.LogError("physics not update");
}
// do other stuff
}
void FixedUpdate()
{
if (RenewGamePhysics)
{
PhysicsUpdated = true;
RenewGamePhysics = false;
}
}
please ignore the “iter” variable since I added that just to break out of the while loop, cause currently Unity waits endlessly for the FixedUpdate to run.
So what am I doing wrong here? Any help is greatly appreciated.
More info - I’m using 2019.26f if it helps.