Creating Polygon Colliders


  1. Add an instance of the rock sprite to the scene. Refer to Creating a sprite in the editor if you need detailed steps in doing this.

    img/CreatingRock.png

  2. This sprite won't be represented well by a box, so we will create a polygon collider instead. Select the sprite collection and click "Open Editor...".

  3. Select the rock sprite in the sprite collection editor.

    img/SelectRock.png

  4. Switch the Collider Type to Polygon. This will give you a box covering the entire texture. We will be shaping this rock to better suit the shape of the rock.

    img/SwitchToPolygon.png

  5. Switch the sprite view to collider edit mode.

    img/ColliderEditMode.png

  6. Roughly match the shape by moving the polygon control points. Simply click and drag them to the desired position. Dont forget that you can zoom in using the mouse wheel or the 2 finger scroll gesture on Mac.

  7. Double click on an edge to add a control point. Click and drag this to position it. More shortcut keys are listed in the right panel.

  8. Repeat the previous step until you have a suitable shape to represent this rock.

    img/PolygonFinal.png

  9. Click commit to save your changes. The rock in the scene should now contain a mesh collider with the shape you defined.

    img/PolygonScene.png

Note: It is not possible to animate polygon colliders at the moment. 2D Toolkit will create the first collider and will not animate it.