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
- Channel remapping dropdown in the Terrain Layer does not open when clicked on the title
- The Editor freezes indefinitely when a large number of elements are entered in the Subgraphs or Categories lists
- Some Visual Effects package Assets links to documentation are not working
- Heatmap asset’s documentation button in the Inspector window leads to “Sorry... that page seems to be missing!” page when clicked
- Crash on MonoBehaviour::CallMethodIfAvailable when performing various actions
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.