Search Issue Tracker
Fixed
Fixed in 2022.3.13f1, 2023.1.20f1, 2023.2.0b17, 2023.3.0a13, 7000.0.0a1
Votes
1
Found in
2022.3.0f1
2023.1.0a4
2023.2.0a6
2023.3.0a3
Issue ID
UUM-53717
Regression
No
[Physics2D] No reason why it has to be consecutive vertices in customCollider2D.SetCustomShapes(shapes, vertices) and error is outputted "ArgumentException: An invalid PhysicsShape at index 1 was encountered"
When using the overload of CustomCollider2D.SetCustomShapes] that allows passing two NativeArray of PhysicsShape2D and Vector3 vertices, the physics shapes are constrained to only use consecutive vertice between shapes i.e. no unused vertex are allowed and will produce a console warning and not set the physics shapes.
—
What happened?
[https://forum.unity.com/threads/2d-physics-in-unity-2022-1.1327701/#post-9411431]
How can we reproduce that?
The following code leads to an error: "ArgumentException: An invalid PhysicsShape at index 1 was encountered. The CustomCollider2D was not updated."
{code:java}
var shape = new NativeArray<PhysicsShape2D>(2, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
var vertices = new NativeArray<Vector2>(8, Allocator.Temp);
vertices[0] = new Vector2(1, 1);
vertices[1] = new Vector2(1, 2);
vertices[2] = new Vector2(2, 1);
vertices[3] = new Vector2(2, 2);
vertices[4] = new Vector2(1, 1) * 2;
vertices[5] = new Vector2(1, 2) * 2;
vertices[6] = new Vector2(2, 1) * 2;
vertices[7] = new Vector2(2, 2) * 2;
shapes[0] = new PhysicsShape2D { shapeType = PhysicsShapeType2D.Polygon, vertexStartIndex = 0, vertexCount = 3 };
shapes[1] = new PhysicsShape2D { shapeType = PhysicsShapeType2D.Polygon, vertexStartIndex = 4, vertexCount = 3 };
_customCollider.SetCustomShapes(shapes, vertices);
shapes.Dispose();
vertices.Dispose();
{code}
EDIT: I've created and attached a case demonstrating the issue - Melv.
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
- "Shader warning in 'Hidden/Light2D': implicit truncation of vector type" is thrown when building Universal 2D template
- AI Assistant breaks compilation of packages using System.Runtime.CompilerServices.Unsafe via auto-referencing
- Unity Hub checks the "Documentation" module by default on the 6.4 and 6.5 streams despite that it was unchecked with the previous installs
- Shortcut that toggles between Dopesheet and Curves Views in the Animation Window's Timeline is mislabed
- Property List Items Overlap onto the Property List's top edge when scrolling through a long Property List
Resolution Note (fix version 2023.3.0a13):
Fix for this issue is available on Unity 2023.3.0a13 and above
Resolution Note (fix version 2023.2.0b17):
Fix for this issue is available on Unity 2023.2.0b17 and above
Resolution Note (fix version 2023.1.20f1):
Fix for this issue is available on Unity 2023.1.20f1 and above
Resolution Note (fix version 2022.3.13f1):
Fix for this issue is available on Unity 2022.3.13f1 and above