Search Issue Tracker
In Progress
Fix In Review for 2022.3.13f1, 2023.1.20f1, 2023.2.0b17, 2023.3.0a13
Fixed in 2024.1.0a1
Votes
1
Found in
2022.3.0f1
2023.1.0a4
2023.2.0a6
2023.3.0a3
2024.1.0a1
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|[https://docs.unity3d.com/ScriptReference/CustomCollider2D.SetCustomShapes.html]] 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.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- A vertical graphical artifact appears on Android Player when clearing Z & Stencil Buffer and running with OpenGLES3 Graphics API
- Player crashes when built with IL2CPP Scripting backend
- TextMeshPro package throws multiple Shader errors when importing TMP Essential Resources
- Package Manager search text field has no validation and leads to Editor freezes
- PlayerLoop.SetPlayerLoop() function is ignored when playing game in Player
Add comment