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
- Label is not centered when using flex-direction: row
- Incorrect initial target position when the Skinning Editor's "Depth" parameter is adjusted on a bone which is set as the "Effector" parameter on the "Limb Solver 2D" Component
- The order of activation for Water Deformers and Foam Generators will cause water artefacts in the Player
- Crash on `anonymous namespace'::PrepareTreesAndWriteWindParamsJobData::Execute when entering Play mode on a specific project
- Crash on CachedWriter::Write when building a specific project with a default runtime TSS
Add comment