Search Issue Tracker

By Design

Votes

0

Found in

2021.3.45f1

2022.3.50f1

6000.0.23f1

Issue ID

UUM-84233

Regression

No

OnTriggerExit2D is called in Play mode when undoing component adding

--

-

Reproduction steps:
1. Open the attached “ReproProj” project
2. Open the “Assets/trigger-event-test“ scene
3. Enter the Play mode
4. Select the “Small Object 2D” GameObject in the Hierarchy view
5. Add any component to the GameObject
6. Undo the component adding via CTRL+Z
7. Observe the Console logs

Expected Result: No OnTriggerExit2D logs are thrown
Actual Result: OnTriggerExit2D is called

Reproducible with: 2021.3.45f1, 2022.3.50f1, 6000.0.23f1

Reproducible on: Windows 11 Pro
Not reproducible on: No other environments tested

Note: Not reproducible with 3D Colliders

  1. Resolution Note:

    This is not a bug. Undo is not controlled by 2D/physics and fundamentally it disables/enables the components in a GameObject.

    In 2D physics, it has a feature that will produces Exit callbacks when a physics object is disabled/destroyed at runtime (in playmode). This is entirely expected behavior.

    In 2D, this is controlled by the option: https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Physics2D-callbacksOnDisable.html which also can be set in the physics settings.

    If the user does not want this then they can simply disable this option.

    3D physics does not have this feature and does not produce such a callback, but it is not a rationale to infer a bug for 2D physics

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.