Search Issue Tracker
By Design
Votes
0
Found in
2018.2.10f1
Issue ID
1087650
Regression
No
"OverlapPoint" not detecting "CompositeColliders" when cell size is less than '1'
Reproduction steps:
1. Open "MinimalRepro" project and "scene" scene
2. Enter Play mode
3. Look at the Console window and see 24 lines printed
4. Exit Play mode
5. Select "Tilemap" in the Hierarchy window
6. Uncheck "Use Comp Collider" in "Comp Coll Test(Script)" and "Used By Composite" in "Tilemap Collider 2D"
7. Enter Play mode
8. Look at the Console window and see 24 lines printed
9. Select "Grid" in the Hierarchy window
10. Change "Cell Size" 'x' and 'y' values from '1' to '0.5'
11. Enter Play mode
12. Look at the Console window and see 11 lines printed
13. Exit Play mode
14. Select "Tilemap" in the Hierarchy window
15. Check "Use Comp Collider" in "Comp Coll Test(Script)" and "Used By Composite" in "Tilemap Collider 2D"
16. Enter Play mode
Expected Result: The Console window prints 11 lines
Actual Result: The Console window doesn't print anything
Reproduced with: 2019.1.0a7, 2018.3.0b8, 2018.2.14f1, 2018.1.9f2, 2017.4.14f1
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
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
Resolution Note:
"OverlapPoint" on "EdgeCollider2D" or "CompositeCollider2D" (using "Outline" geometry mode) always failed before, because "Box2D" (the 2D physics engine we use) didn't support point checks on edges but we added support for this when the "Edge Radius" was developed for some colliders including the "Outline" geometry mode of the "CompositeCollider2D". If you did specify a radius on the edge then the edge is no longer infinitely thin so it's correct to expect "OverlapPoint" to detect "inside" the line as it's really a capsule then. We also made it that if you set the line back to zero edge radius then "OverlapPoint" should still detect it but it would only do so when the point is exactly on the line.
In the case, the initial test uses integers as world-space coordinates so ends-up testing a million integer coordinates which when converted to floating point in "Vector2" do happen to overlap some of the edges but only some of them. If you add (say) '0.001' to the coordinates being tested then it'll fail to detect those edges, it happens to detect others if they are exactly at that point which probably isn't that likely.
When you change the scale to 0.5 you're just moving around these edges and the likelihood of the edges overlapping those exact points is low but you can do it.
When you turn off the "Use By Composite" on the "TilemapCollider2D", all you're doing then is reverting back to what the "TilemapCollider2D" does which is creating polygons, not lines. Polygons are closed shapes so overlap point isn't checking edges, it checks the area inside the polygon so it's much more likely to hit them.
The main thing to note here is that "OverlapPoint" is only really useful when you're not using infinitely thin lines i.e. lines with an "Edge Radius" of zero and is more useful in closed shapes i.e. "BoxCollider2D", "CircleCollider2D", "CapsuleCollider2D", "PolygonCollider2D" etc.
Pictures for reference:
https://i.gyazo.com/f66cdc68ca86611fc1f80ab9ff35f140.png
https://i.gyazo.com/4c51ed9eb411aa0c355785a40422c279.png
https://i.gyazo.com/f82701314b91a711775fd9c7d365da30.png