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
- "Playmode tint" is applied to Color and Gradient fields when in Play mode
- [HDRP] Scene corrupts when baking Reflection Probe with custom TextureImporter preset added to Texture Importer default
- HDRP Wizard window UI components overlap when HDRP Wizard window is docked and resized horizontally
- VideoPlayer component fails to play MP4 files located under the StreamingAssets folder
- Terrain Tools icons are low quality
Add comment