Search Issue Tracker
By Design
Votes
0
Found in
2021.3.41f1
2022.3.39f1
6000.0.12f1
Issue ID
UUM-77259
Regression
No
OnTriggerExit2D is called before OnTriggerEnter2D for same object when Instantiating a GameObject in same position of destroyed object
How to reproduce:
1. Open the attached “Piggy Games Test.zip” project
2. Open the “SampleScene”
3. Enter Play Mode
4. Observe the Console Window
Expected result: No errors are shown and OnTriggerExit2D is called after OnTriggerEnter2D
Actual result: OnTriggerEnter2D is called after OnTriggerExit2D and causes an error “MissingReferenceException”
Reproducible in: 2021.3.41f1, 2022.3.39f1, 6000.0.12f1
Reproducible on: Windows 11
Not reproducible on: No other environment tested
Note: Sometimes may take some time to get the error
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Console shows Exception: {"error":"not found","detail":["not found"]} after opening Build History window
- [HDRP] Volumetric cloud shadows disappear when there is no directional light shadows
- “Selector” column names in the Search window are lowercase when added
- Install List Project Counter Panel can be right clicked through and Install Context Menu can be opened disabling Project Counter Panel's buttons
- [MacOS] Scene is marked/flickering as dirty (with asterisk) when dragging a Material on a GameObject in Scene view
Resolution Note:
The issue here lies with the way you are adding and removing the enemies from the “_targets” element. Since both archers can target the same Enemy, that creates the issue. Once one archer Destroys the Enemy, the second archer cannot access to Destroy the Enemy since the value is already null in the list.
The fix to this could be that both archers have different lists of targets and couldn’t target an enemy that is already in the other archers list of targets. Another suggestion could be that you remove the specific Enemy that was hit, and not the first entry in the “_targets” list.