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
7000.0.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.
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
- A 404 page is opened when selecting "Open Documentation" on the Float Node in Shader Graph
- Shader Graph Importer's Documentation Reference button leads to a 404 page
- Crash on WriteParticleLineVertex when particle systems are rendered in a specific project
- Asset names longer than the allowed system file path are not handled gracefully
- Moving VFX Particles leave a ghosting trial in Ray Traced Screen Space Reflections
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