Complete the code to add a BoxCollider2D component to the GameObject.
gameObject.AddComponent<[1]>();The BoxCollider2D component adds a box-shaped collider to the GameObject.
Complete the code to add a CircleCollider2D component and set its radius to 2.5.
var collider = gameObject.AddComponent<[1]>(); collider.radius = 2.5f;
The CircleCollider2D component adds a circular collider, and the radius property sets its size.
Fix the error in the code to add a PolygonCollider2D component.
PolygonCollider2D collider = gameObject.AddComponent<[1]>();The PolygonCollider2D component is added using its exact type name inside the AddComponent<> method.
Fill both blanks to create a BoxCollider2D and set its size to (5, 4).
var collider = gameObject.AddComponent<[1]>(); collider.size = new Vector2([2], 4);
Use BoxCollider2D to add the box collider, and set the size property with a Vector2 where the width is 5 and height is 4.
Fill the two blanks to add a PolygonCollider2D, set its path count to 1, and define a triangle shape.
var collider = gameObject.AddComponent<[1]>(); collider.pathCount = [2]; collider.SetPath(0, new Vector2[] { new Vector2(0,0), new Vector2(1,0), new Vector2(0,1) });
Use PolygonCollider2D to add the polygon collider, set pathCount to 1 to define one shape, and use SetPath to set the triangle points.