NativeBox2D - The best 2D physics solution for Unity3D

NativeBox2D is a native plugin to provide Box2D functions in Unity environment without performance loss, NativeBox2D integrates Box2D seamlessly into Unity and suppose to be the best 2D physics solution for Unity.

Among the features provided in NativeBox2D are:

NativeBox2D APIs:

  • b2World methods support.
  • b2Body methods support.
  • b2Fixture methods support.
  • all joints methods support.
  • ContactListener, ContactFilter, QuerryAABB, Raycast callbacks support.

A component based wrapper layer around the APIs:

B2DWorld

  • A b2World in Unity.

B2DBody

  • A b2Body in Unity.

B2DBoxShape
B2DCircleShape
B2DPolygonShape
B2DEdgeShapes

  • Provide a shape for collision as their names suggest.

DistanceJoint
FrictionJoint
GearJoint
MouseJoint
PrismaticJoint
PulleyJoint
RevoluteJoint
RopeJoint
WeldJoint
WheelJoint

  • Provide a Box2D joint as their names suggest.

BeginContact
EndContact
OnFixtureDestroy
OnJointDestroy

  • Messages sent by NativeBox2D, check Tests/CallbackTest.cs for sample usage.

Please check Example.scene for the basic usage of these components, as well as Testbed.scene for the usage of NativeBox2D API.

Notice:
Build for Windows standalone, Mac OSX standalone, Android is as easy as just Build&Run.
Build for iOS, please check Plugin/IOS/readme for detail instructions.

Asset Store Link: http://u3d.as/content/mys-game-studio/native-box2d/3wr

Support from zhouxuan et mnysoft.com

Changelogs:

V1.3
Add XCode/Visual Studio project files. So everyone can add/remove features and build from sourcecode.
Add b2Contact interfaces.

V1.4
Revert project to Unity 3.5

V1.5
Add Manifold support.

Nice ,is the complete API implemented?

Almost all API are implemented, however, if you find any function absence , feel free to post a feature request.

The integration is full source or compiled dll?

compiled dll

Hmmmm, looks cool. Have you done any perf. comparisons to the native PhysX? Between similar 2D scenes, of course

Looks good. Does it work with a free Unity license?

Unfortunately then I have to pass cos there’s too many abandoned packages.

So it’s Windows only?

On second thought, I decide to add the source code to package in case I get involved in more important things.
Announcement goes here when it’s ready, stay tuned.

No, it works on Windows, Mac, iOS and Android.

I dont think so, native plugin is a pro only feature.

I construct a scene with 10 ropes, 30 nodes each. It turns out that NativeBox2D is 5%-10% faster than built-in physics.

PhysX support multi-threading, even hardware accelaration, make it very impressive in performance, however, when do 2D physics, it’s not very stable, especially do fast-moving physics, as well as lack of mouse joint, so I made NativeBox2D for my game.

Hi, all, source code for dll is included in V1.02. Please check the link : http://u3d.as/content/mys-game-studio/native-box2d/3wr

I saw the demo for box2d a few weeks ago and it looked very impressive. Probably the main reason I was thinking about going for cocos2d before deciding on unity. Might give this a try, and hopefully it keeps getting supported :slight_smile:

Hello pycerl,

Looks interesting, but does NativeBox2D have any documentation on how to use it inside unity?

Also there is another plugin called “Box2D for unity” it does have many nice examples, so are you planing to include more example?

Thanks

It’s a thin wrapper around Box2d, if you know how to use Box2D, you know how to use NativeBox2D as well I think, however, you can always contact me at pycerl et qq.com.

Box2D for Unity is a C# port of Box2D. Runtime performance is bad compared with its original C++ version.
NativeBox2D is a wapper around original Box2D, so it’s supposed to run as fast as it.

Source code in C++ is included, so feel free to try it. :slight_smile:

Hi!,

I’m really interested in this port. Does it work on indie version of Unity3D? Has been used in production? Are there any docs, example scenes to see it in action?.

Thanks in advance.

Sorry, it doesn’t work on indie version. I’m using it in a project and it works well, some example scenes are included as well.