Search Issue Tracker
By Design
Votes
0
Found in
5.0.0f4
Issue ID
706239
Regression
No
[Physics2d] Collider2d.attachedRigidbody throws exceptions from destroyed gameobjects
To reproduce:
1. Open attached project
2. Open scene test
3. Enter play mode. Cubes will start moving into a green square, which destroys them. Along this, a 'OnTriggerStay2d' is being called and Collider2D.attachedRigidbody is being used for setting the velocity of the cubes.
Once this happens to a cube that's been called on Destroy(GameObject) - exceptions get thrown. This does not happen consistently, but once every few cubes.
If I use GetComponent<Rigidbody2D>() in the Conveyor script instead, I get no exceptions.
Explanation: The option of Physics2D 'changeStopsCallbacks' has been turned-off which means that even if an object involved in the callback has been deleted during callback processing then any remaining callbacks should continue.
The exception is caused by accessing the Rigidbody2D which has been deleted. Either turn-on the 'changeStopsCallbacks' or ensure that you check that the Rigidbody2D is not null before accessing its members.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Frame Debugger's Hierarchy is not navigable when connecting it to the project built with the Volumetric Fog
- The number of SetPass Calls is increasing when attaching the Frame Debugger to the Player
- Scrollbar briefly appears in the Package Manager during installation process even when the package list is too short to require scrolling
- Script resets to use the previous Skybox color when saving the Scene changes
- [2D] Sprite Library Editor window throws NullReferenceException error when entering Play Mode with Game View maximised
Add comment