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
- Fixing Message Loss in UMPE During Domain Reload
- The Editor freezes when ScheduleReadOnly of IJobParallelForTransform with dependency is used
- Text is truncated in the Inspector when the display scale is set to 150%
- CancellationTokenSource(<timeout>) has incorrect cancellation status when used in WebGL Player
- VFX property value names are cut off when properties with 'Arc' are viewed in the VFX Blackboard
Add comment