Version: Unity 6.7 Beta (6000.7)
Language : English
Add physics to a sprite with 2D Physics Core
Merge 2D Physics Core shapes

Create complex shapes with 2D Physics Core

Build a shape out of vertices you place yourself, rather than a primitive shape such as a circle or capsule.

Note: This documentation is about using Pose, Area, and Constraint components. To use 2D physics in the Unity Editor using components like the Rigidbody 2D component, refer to 2D physics instead.

You can create one of the following:

  • Path: A line that acts as a one-sided barrier.
  • Polygon: A single filled polygon. Concave sections aren’t allowed.
  • Contour: A custom shape, which can be an outline or filled. Concave sections are allowed.

To combine multiple shapes into one shape, refer to Merge 2D Physics Core shapes.

Create a path

To create a path that acts as a one-sided barrier, follow these steps:

  1. Select a GameObject in the Hierarchy window, or create an empty GameObject.

  2. In the Inspector window select Add Component, then Physics 2D (Core) > Physics Pose.

  3. Select Add Component again, then select Physics 2D (Core) > Physics Area Path.

    By default, the path is a line formed from two vertices. If you don’t need more than two vertices, add a Physics Area Segment component instead.

  4. Select Add Start Vertex or Add End Vertex to add a vertex to the path.

You can also add, move, and remove vertices directly in the Scene view. For more information, refer to Visualize and edit 2D Physics Core scenes.

To change which side of the path other objects collide with, set the Winding property to CW (clockwise) or CCW (counter-clockwise).

Unity automatically creates an invisible extension of your path at either end, to make sure collisions with the ends of the path are accurate. Unity displays these extensions in the Scene view as dotted lines.

For the full list of properties, refer to Physics Area Path component reference.

Create a polygon

To create a single convex polygon, follow these steps:

  1. Select a GameObject in the Hierarchy window, or create an empty GameObject.
  2. In the Inspector window select Add Component, then Physics 2D (Core) > Physics Pose.
  3. Select Add Component again, then select Physics 2D (Core) > Physics Area Polygon.
  4. Set the Count property to the number of vertices you want the polygon to have.

You can edit the vertices in the Inspector window, or edit the polygon directly in the Scene view. For more information, refer to Visualize and edit 2D Physics Core scenes.

To round the corners of the polygon, set the Radius property to a value greater than 0.

For the full list of properties, refer to Physics Area Polygon component reference.

Create a contour

To create an outline or filled shape, follow these steps:

  1. Select a GameObject in the Hierarchy window, or create an empty GameObject.

  2. In the Inspector window select Add Component, then Physics 2D (Core) > Physics Pose.

  3. Select Add Component again, then select Physics 2D (Core) > Physics Area Contour.

    By default, the component contains one contour, the four vertices of a square.

  4. Set Output to Segments for an outline shape, or Polygons for a filled shape.

  5. To add another vertex to a contour, select Add Vertex.

You can edit the vertices in the Inspector window, or edit contour vertices directly in the Scene view. For more information, refer to Visualize and edit 2D Physics Core scenes.

To change which side of the path other objects collide with, set the Winding property to CW (clockwise) or CCW (counter-clockwise).

Select Add Contour to add another shape. For more information, refer to Merge 2D Physics Core shapes.

For the full list of properties, refer to Physics Area Contour component reference.

Additional resources

Add physics to a sprite with 2D Physics Core
Merge 2D Physics Core shapes