Search Unity

NativeBox2D - The best 2D physics solution for Unity3D

Discussion in 'Assets and Asset Store' started by pycerl, Oct 30, 2012.

  1. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    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.
     
    Last edited: Mar 19, 2013
  2. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Nice ,is the complete API implemented?
     
  3. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    Almost all API are implemented, however, if you find any function absence , feel free to post a feature request.
     
  4. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    The integration is full source or compiled dll?
     
  5. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    compiled dll
     
  6. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    616
    Hmmmm, looks cool. Have you done any perf. comparisons to the native PhysX? Between similar 2D scenes, of course
     
  7. Kusmi

    Kusmi

    Joined:
    Jul 16, 2012
    Posts:
    6
    Looks good. Does it work with a free Unity license?
     
  8. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Unfortunately then I have to pass cos there's too many abandoned packages.
     
  9. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    So it's Windows only?
     
  10. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    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.
     
  11. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    No, it works on Windows, Mac, iOS and Android.
     
  12. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    I dont think so, native plugin is a pro only feature.
     
  13. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    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.
     
  14. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
  15. sargent

    sargent

    Joined:
    Oct 30, 2012
    Posts:
    3
    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 :)
     
  16. bravery

    bravery

    Joined:
    Mar 26, 2009
    Posts:
    270
    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
     
  17. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    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.
     
  18. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    Source code in C++ is included, so feel free to try it. :)
     
  19. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    443
    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.
     
  20. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    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.
     
  21. Kusmi

    Kusmi

    Joined:
    Jul 16, 2012
    Posts:
    6
    Hello there,

    I just bought NativeBox2D. I tried to launch the test scenes on my iMac (Snow Leopard, 10.6.8, 32 bits kernel) but I get a flow of errors right after pressing the play button in the editor:

    NativeBox2D_Scene.unity
    I copied my test project on another iMac running Mac OS X Mountain Lion (10.8.2, 64 bits kernel) and everything is running perfectly fine.
    Out of curiosity, I rebooted my Snow Leopard iMac with a 64 bits kernel but no luck, same errors.

    Does NativeBox2D require a specific Mac OS X version?

    My specs:
    Unity 3.5.6f4 Pro
    Mac OS X 10.6.8 (tried with 32 64 bits kernels)
    iMac Model 11,2 - 3.06GHz Intel Core i3 / 4Go / Radeon HD 4670 256Mo
     
    Last edited: Dec 6, 2012
  22. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    The plugin binary for Mac OS X is 64bit only, if you want a 32bit one, please compile it from the source code targeting 32bit.
     
  23. artonator

    artonator

    Joined:
    Sep 12, 2009
    Posts:
    69
    Do you have any web demo that I can take a look?
     
  24. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    Sorry, It doesn't support web platform because of the usage of native plugin.
     
  25. artonator

    artonator

    Joined:
    Sep 12, 2009
    Posts:
    69
    Dose it support Mobile platforms?( IOs, Android, WIndows...)
     
  26. itjunkii

    itjunkii

    Joined:
    Dec 1, 2011
    Posts:
    35
    Hello,

    I have a Mid 2010 Macbook Pro x64

    I import from the Asset Store and I get a DLLNotFoundException: NativeBox2D

    What am I missing?
     
  27. NarooNaroo

    NarooNaroo

    Joined:
    Oct 10, 2012
    Posts:
    1
    Hi,

    Can I use this with other 2d plugins like 2d toolkit or ex2d?
     
  28. artonator

    artonator

    Joined:
    Sep 12, 2009
    Posts:
    69
    Is this plug in still supported?
     
  29. itjunkii

    itjunkii

    Joined:
    Dec 1, 2011
    Posts:
    35
    Beware you need Unity Pro License or you cannot use it.
     
  30. artonator

    artonator

    Joined:
    Sep 12, 2009
    Posts:
    69
    I use pro though It need to work on mobile and web as well... and I need to know if it is still supported by developer...
     
  31. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    Web is not supported as well as Flash/NACL.
    Andoird/iOS/Mac OSX/Windows/Linux are well supported.
    FYI: tech support via zhouxuan et mnysoft.com
     
  32. angryhawk

    angryhawk

    Joined:
    Jan 18, 2013
    Posts:
    1
    Hi Pycerl, I just purchased this plugin and tested out. In the contact listener, BeginContact and EndContact, how do I get which body begin contact with which body? I don't see any function that would allow one to do this. Normally, in Box2D, I would get the fixtures A, B of bodies in contact and then from fixture get the shape and then body. There don't seem to be a function to allow on to do that yet.

    This is absolutely a critical function to have in order to make any game out of Box2D. Do I miss anything? Thanks in advance!
     
  33. gmentat

    gmentat

    Joined:
    Nov 12, 2012
    Posts:
    15
    Hello Pycerl,
    Thanks for such great port of Box2D!

    Can you tell me what version of Box2D it is using?

    I'm asking because I need the userData in b2Body and the current version of the API doesn't seems to offer it, so I'm going to recompile the lib file. Also is there any chance of getting the xcode project? :)
     
  34. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    It uses Box2D V2.2.1
     
  35. tobo

    tobo

    Joined:
    Feb 14, 2013
    Posts:
    2
    Since the last update, Unity 4 is required.
    Is it still working in Unity 3.5?
     
  36. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    Yes, the plugin itself is compatible with Unity 3.5, however, once you open the 4.0 project with Unity 3.5 ( by removing Library folder manually and clicking "continue and risk data loss"), the test scenes will not work, every script is missing and you need to reattach proper one for each GameObject manually, by doing this, it works like a charm.
    Sorry for such an inconvenience, I'm thinking of using Unity 3.5 for next update.
     
  37. tobo

    tobo

    Joined:
    Feb 14, 2013
    Posts:
    2
    Thank you, without Unity 4 people will not be able to download this plug-in.

    I have this error when trying to use your plug-in with Windows 64bit / Unity 3.5:
    DllNotFoundException: D:/Public/NativeBox2d/NativeBox2d/Assets/Plugins/NativeBox2D.dll

    Also, I had a look with Dependency Walker at the NativeBox2D.dll and I see that you compiled it in Debug mode (MSVCP/R100D.DLL)?
     
    Last edited: Feb 18, 2013
  38. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    It's really a silly bug, I'll update it asap. Thank you very much!
     
  39. NargalaX

    NargalaX

    Joined:
    Mar 27, 2012
    Posts:
    6
    I found the solution.

    I was getting DLLNotFoundException errors and did some research and found this post, which recommends to download a program called CFF to check dependency on the dll.

    I downloaded CFF and checked NativeBox2D.dll and it showed that I was missing MSVCR110.dll.
    After researching what that meant, it turns out that everyone NEEDS to have Visual C++ Runtime (I'll assume 2010, or whatever version OP compiled it with) otherwise they can not use the .dll provided.

    I didn't have Visual Studio installed at the time (I use a different IDE) and so I decided to install the entire thing, including the runtime, to cover all my bases. It worked!

    You can download Visual Studio here if you have the issue.

    Good luck everyone and happy coding!

    -Nargalax
     
  40. Game-Whiz

    Game-Whiz

    Joined:
    Nov 10, 2011
    Posts:
    122
    Hi,

    Could you please post a performance comparison of NativeBox2d vs PhysX? I saw this: http://unity3d.com/ninjacamp/projects/10080 but I'll gladly buy your plugin to anticipate this functionality, if the performance is 2x to 20x like Aras is claiming for Chipmunk.

    Thanks,
    Alex
     
  41. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Why exactly is there a price on this plugin. The Original Box2D is free and opensource...
     
  42. Armitage1982

    Armitage1982

    Joined:
    Jul 26, 2012
    Posts:
    38
    Hi

    I send you a PM about the missing Chain Shapes a few days ago but don't know if it's the right way to ask about support.

    Wouldn't you mind elaborate a bit on the missing part of Box2D ?
    Thanks
     
  43. Armitage1982

    Armitage1982

    Joined:
    Jul 26, 2012
    Posts:
    38
    By the way, it's not possible to use the Edge Shape to mimic a Chain Shapes because we need to have access to m_hasVertex0 m_hasVertex3 m_vertex0 m_vertex1 m_vertex2 m_vertex3 in order to eliminate the ghost collision caused from internal normal.

    From what I see you wrap every methods and create Get/Set functions to access Public Attributes.
    It's also good to mention that the asset is using pointer everywhere and not identifiable Box2D objects.
     
  44. mslinklater

    mslinklater

    Joined:
    Mar 1, 2013
    Posts:
    44
    You're paying for the time spent encapsulating Box2D into a Unity package. IMO the asking price is well worth it. You are of course free to do it all yourself for free too.
     
  45. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    I am thankful for this, of course, but the thing is: the original one wasn't just encapsulated, it was built from zero, but it still is free.

    For example: There is a Farseer-Port for Unity, which is also for free, like the Original Farseer.
     
  46. Amon

    Amon

    Joined:
    Oct 18, 2009
    Posts:
    1,384
    It's worth the money. Sheesh! Time was spent putting this all together and that time is worth the asking price for this. Like the guy says, if you don't want to pay for the time he put in to get this all working for you in Unity then by all means go code it, put it together yourselves. If you value your time then the asking price is fair and worth it.
     
  47. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    It's not about worth of the money. It's about the principle.
    But i don't quite understand why the developers of the original C++ engine decided to make it open-source and free (and just get money via donations, which I already did!) and the Port to Unity costs money?

    It's like a game for iOS is for free and the Android-Version has a price.

    Nevertheless, I know how much work the developer spent for this Port, and i appreciate it!
     
  48. Amon

    Amon

    Joined:
    Oct 18, 2009
    Posts:
    1,384


    Yes! the PORT to Unity costs because time was invested to make the Port.

    No worries though, I'll say no more. I'm pretty sure though that no matter what, the free brigade will never understand or see why something costs money.
     
  49. pycerl

    pycerl

    Joined:
    Oct 25, 2012
    Posts:
    18
    Sorry, I thought you guys see the email address I left, however, please email zhouxuan et mnysoft.com for support, thank you!
     
  50. Armitage1982

    Armitage1982

    Joined:
    Jul 26, 2012
    Posts:
    38
    Now I see it ^^
    Didn't spot any email for support before, sorry...