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
- UI Text color is incorrect when text is rendered on SubMeshUI
- "Invalid SortingGroup index set in Renderer" errors when making many modifications in same frame
- Crash on GizmoBufferSizeHistory::GetBuffer() when opening a specific scene
- RenderTexture is not initialized when it is set as Material's Texture
- Branch node outputs a random value instead of a constant on the false conditon
Add comment