---
title: "How to create physics shapes for Defold"
description: "Learn how to create physics collision shapes for Defold Game Engine."
canonical: "https://www.codeandweb.com/physicseditor/tutorials/how-to-create-physics-shapes-for-defold"
date: "2024-06-06T00:00:00.000Z"
modified: "2024-06-06T00:00:00.000Z"
source: "html"
---

# How to create physics shapes for Defold

Joachim Grill

[physicseditor](https://www.codeandweb.com/tags/physicseditor),  [defold](https://www.codeandweb.com/tutorials/defold.md),  [tutorial](https://www.codeandweb.com/tags/tutorial)

![How to create physics shapes for Defold](https://www.codeandweb.com/static/9852d2d7aa52c16b264ac5041a878d46/a6312/post-image.png)

PhysicsEditor is a powerful tool for creating and editing collision shapes for 2D games. Here's a short tutorial on how to use PhysicsEditor with the Defold game engine:

## Step 1: Install and set up PhysicsEditor

Download PhysicsEditor from CodeAndWeb and install it on your system:

[Download PhysicsEditor 2.1.0](https://www.codeandweb.com/physicseditor/download/2.1.0/win)

for Windows

[Also available for macOS and Linux](https://www.codeandweb.com/physicseditor/download.md)

Launch PhysicsEditor and select the Defold exporter from the **Exporter** dropdown on the right sidebar:

![PhysicsEditor: select Defold from the Exporter combobox](https://www.codeandweb.com/static/25e9901d3711504b179f6e11b2625df7/a2c3c/physicseditor-defold-exporter%402x.png)

## Step 2: Import sprites

Click on **Add Sprites** or drag and drop your sprite images into PhysicsEditor's left sidebar.

![PhysicsEditor: add sprites by clicking the toolbar button](https://www.codeandweb.com/static/cc6fc62213a8cc9a4263125dfedccd6d/5e186/physicseditor-add-sprites%402x.png)

Select a sprite and edit its collision shape using the provided tools. You can manually adjust the vertices or use the automatic shape tracer.

![PhysicsEditor: Tools to create collision shapes](https://www.codeandweb.com/static/479cdd750eae66c911ce59b0b520f489/11414/physicseditor-tools%402x.png)

## Step 3: Configure shape properties

Use the input fields on the right sidebar to set the shape type (Static, Dynamic, ...) and other properties like Mass, Friction, etc., according to your game needs.

![PhysicsEditor: set fixture properties](https://www.codeandweb.com/static/bf8ac106cb52a57228654e7a57413e35/64db2/physicseditor-fixture-properties%402x.png)

PhysicsEditor will generate Game Objects containing the Collision Objects as well as the Sprite components. Use PhysicsEditor's **Atlas path** input field to specify the texture atlas of your Defold project which contains the sprite images.

## Step 4: Export collision shapes

Set **Shape path** to the relative path of the directory to which you are going to export the physics shapes (relative to the Defold project folder, which contains `game.project`).

To export the collision shapes, click on the **Publish** button in the toolbar. Then select a subdirectory within your game project folder to which the shapes should be published.

![PhysicsEditor: press publish to export the collision shapes](https://www.codeandweb.com/static/2d2649b1642c28a8b739a04cddc6cd67/52bcc/physicseditor-publish%402x.png)

## Step 5: Import to Defold

For each sprite, PhysicsEditor has generated a _Game Object_ in your Defold project directory. Open your scene (e.g., _main/main.collection_) and select **Add Game Object File** in the context menu of the **Outline** view to add the Game Object generated by PhysicsEditor.

![Defold editor: use context menu to add Game Object File](https://www.codeandweb.com/static/1d81cf9380addf78a2f71c6197a91f2d/9f339/defold-add-game-object-file%402x.png)

> **Warning:** Defold doesn't allow adding both a circle and a polygon shape to one _Collision Object_, nor does it support multiple polygon shapes in one _Collision Object_. It also does not support setting per circle shape properties, if more than one circle is assigned to a _Collision Object_. That's why PhysicsEditor automatically creates multiple collision objects, one for each shape. This also applies to concave polygons, as they are automatically split into convex polygons.
>
> Multiple _Collision Objects_ in one _Game Object_ work fine for shape type _Static_, i.e., as long as they are not moved by the physics simulation. For _Dynamic_ objects this configuration cannot be used, as the simulation would result in very erratic shape movements.

## Structured data

```json
{
  "@context": "https://schema.org",
  "@type": "TechArticle",
  "headline": "How to create physics shapes for Defold",
  "author": [
    {
      "@type": "Person",
      "name": "Joachim Grill"
    }
  ],
  "dateModified": "2024-06-06T00:00:00.000Z",
  "image": "/static/9852d2d7aa52c16b264ac5041a878d46/a6312/post-image.png"
}
```
