Search Issue Tracker
Fixed in 2021.2.X
Fixed in 2021.1.X
Votes
0
Found in
2019.4.3f1
Issue ID
1266460
Regression
No
Composite Collider doesn't work with PolygonCollider2D with inverted scale.
How to reproduce:
1. Open the attached project (case_1266460-CompositeColliderWindingIssue.zip)
2. Open the "SampleScene" Scene
3. Select the "Composite" GameObject.
4. Each child GameObject has a BoxCollider2D set to use the composite. One has scale (1,1,1) and the other has scale (-1,1,1). This causes opposite windings.
Expected result: The two boxes should merge together producing a single outline (no hole in the center)
Actual result: The two boxes merge together but don't produce the single output as they have a hole in the center.
The original projects GameObjects also show this but not as clear. The bad behaviour becomes one where the two shapes end up being subtracted from one another in an XOR operation rather than a UNION (OR) operation. NOTE: When checking those GameObjects they will appear to be broken still. This is because the CompositeCollider2D stores the previous calculation. To force a new calculation with the fix, you have to disable/enable the GameObject with the CompositeCollider2D on it.
When a PolygonCollider2D is added to a CompositeCollider2D and it has either its X or Y (not both) axis-sign opposite then this changes the winding of the polygon paths from anti-clockwise to anti-clockwise.
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 (fix version 2021.2):
Using opposing axis scales was causing the winding order to change for the PolygonCollider2D paths. This meant the CompositeCollider2D interpreted them as internal holes when merging. Fixed the winding to be consistent in such cases.
NOTE: To apply this fix to existing CompositeCollider2D geometry, the CompositeCollider2D GameObject will need to be disabled/enabled to trigger it recalculating all geometry. This is because the composite stores the geometry for performance reasons.