Box2D extension

#1

I’ve made a Box2D extension, it’s currently small but very capable already.

To showcase the extension I am preparing a stream on YouTube soon.

15 Likes

#2

I didn’t watch the video completely, but could you please describe what are the key benefits of using this extension instead of the built-in physics? As far as I know it also uses Box2D.

0 Likes

#3

@astrochili I’ll make an overview video at some point. For now here is a brief list:

  • Direct API access. You are not limited by Defold’s collision object interface.
  • Full control of Dynamic and Kinematic bodies. In Defold it’s very hard to control them, for instance there is simply no way to set linear velocity or angular velocity for a body.
  • Multiple simultaneous worlds. You can have as many separate simulations as you want. In Defold there is only one.
  • Control over simulation speed. If you want you can calculate a simulation not in real time, but much faster. For instance it’s possible to simulate trajectory for a projectile over a course of several seconds in just one real-time frame. Not possible in Defold.
  • Virtual bodies. You don’t need visual representation of physics bodies with game objects like sprites. Useful for sensors or invisible walls.
  • Extensibility. The source code of the extension is available. If something is missing in the extension - you can write the code yourself to add it.
  • Latest version of Box2D.

In short, Defold provides an extremely limited access to Box2D functionality, making it very hard to make proper physics based games.

4 Likes

#4

This sounds great. I think it could be especially useful when there will be a possibility to draw custom polygonal shapes. In that way, you’ll be able to make a lot of custom shapes in Tiled editor (a terrain for example) and import them to both Box2D world and some drawing processor. It would be powerful.

When will the library be available to try?

1 Like

#5

At the moment my extension only supports rectangular and round shapes, but polygonal and multishape bodies will be available too at some point.

The extension is already available to my tier 2 patrons on Patreon. That is $5 a month.

3 Likes

Sprites tied to physics lag one frame behind (Issue-4152)