Search Issue Tracker
By Design
Votes
0
Found in
2018.4
2018.4.21f1
2019.4
2020.1
2020.2
Issue ID
1255872
Regression
No
OnTriggerEnter2D is not called when entering Tilemap collider from specific side
How to reproduce:
1. Open attached project "TilemapOnTriggerEnter.zip" and scene "Main"
2. Enter Play mode
3. Observe the moving object
Expected result: the object flips when left wall is touched
Actual result: the moving object goes inside the left wall
Reproducible with: 2018.4.24f1, 2019.4.1f1, 2020.1.0b13, 2020.2.0a15
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
- Standalone Player crashes with "TDerived GetOrLoad<TDerived>() where TDerived : T" when IL2CPP Code generation is set to "Faster (smaller) Builds"
- IndexOutOfRangeException and InvalidOperationException when logging XML string
- Script missing in "Assets/Settings/Mobile_Renderer/GlobalVolumeFeature" of "com.unity.template.urp-blank" template
- “Font Asset Creator - Error Code [Invalid_File_Structure]…“ error is logged when generating Font Assets from fonts with meta files from previous Editor versions
- Input.mousePosition returns (NaN, NaN, 0.00) when Scene view is opened
Resolution Note:
Based on the given project, it seems that everything works correctly according to the given specifications (Collider placement, user script).
OnTriggerEnter2D is called once as the BoxCollider2D it is using contacts the Foreground TilemapCollider2D at the start of the scene, as the BoxCollider2D is placed between the Foreground and the Enemy object. As the BoxCollider2D remains in contact throughout, OnTriggerEnter2D will not be called again. This allows the Enemy object to continue walking through the TilemapCollider2D as the BoxCollider2D is set to IsTrigger.
A different setup may be required to get the behaviour that the user is expecting (eg. shifting the BoxCollider2D higher up so that it does not contact the ground portion of the Foreground TIlemapCollider2D).