I’ve written code that spawns prefabs (such as houses) alongside roads and uses Physics.OverlapBox to detect whether the intended position is valid and doesn’t collide with an existing prefab, that may have been only just instantiated in the same loop.
This worked fine prior to 2018.3 but wasn’t working in recent Unity releases and caused prefabs to overlap each other.
(Definitely ok in 2017.4. I think I tested 2018.2 and it was ok, but I can check if needs be to find out exactly when it changed).
I came to the conclusion that the Physics engine in 2018.3 simply didn’t know about newly instantiated prefabs during the same routine, so couldnt detect when they collided with the OverlapBox.
I concluded there must be a way of updating the physics engine manually and came across Physics.SyncTransforms().
To my delight, calling this after each prefab instantiation updates the physics engine manually and everything works fine now in 2018.3.
I assume Unity has therefore changed how often the physics engine is automatically refreshed to reflect changes to transforms (and new objects in the scene).
In other words, it’s no longer doing it automatically every time a prefab is instantiated in the Editor, which it must have been doing in earlier Unity versions for the code to work correctly.
Can anyone shed any light on this? Is this change documented anywhere, or does it sound like a bug that I now have to call Physics.SyncTransforms() manually after prefab instantaition to achieve this when I didn’t before?
Note that my code runs in the Editor so what I’m describing may be specific to that and not reproducable in run-time code, but I’m curious if anyone knows anything about this.