Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Chipmunk2D for Unity: Faster and more powerful 2D physics.

Discussion in 'Assets and Asset Store' started by slembcke2, Jun 26, 2013.

  1. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    270
    $Logo3.png

    Hello Unity folks.

    I'm a little late posting this here because my old forum account seems to have been disconnected from my email address. :-\ I ended up having to make a new account so now I'm slembcke(2). /me shrugs.

    Anywho. So we've made a native Chipmunk2D plugin for Unity and are running a Kickstarter for it right now. The asset store is the target destination. The Kickstarter is to make sure we can afford the time to document it well, make examples, and support all the major platforms.

    http://www.kickstarter.com/projects/howlingmoonsoftware/chipmunk2d-for-unity

    So why use Chipmunk2D over PhysX? Chipmunk was always built from the ground up as a 2D physics engine, so it doesn't require so many hacks and workarounds to make it work the way you want. I think anybody that's used Unity's CharacterController component has had a bit of a love/hate relationship with it. It doesn't always do what you need it to do, but also does things that aren't exposed through the regular Physics API. It also doesn't really expose a better way to handle controlling a character other than to manipulate a Rigidbody directly or by applying (constraint) forces outside of the physics constraint solver. This doesn't always work great if the object is in contact with any other bodies, especially if they are also controlled outside of the normal physics. Instead of grinding the player's collider across the ground (that's what you are doing after all), why not tell it that the feet are moving separate from it's collision shape and let friction work naturally?

    Why else?
    • Performance!
    • More powerful collision filtering, including the ability to reject collisions in code or modify their parameters.
    • Many more joint types.
    • Editor support that includes visual editing of all the shapes and applicable joints. No more guessing if your joint anchors are positioned correctly.
    • Components function more or less the same as the built-in physics that you already know.
    • Access to nearly the full Chipmunk2D API. It's a very flexible, yet still simple API with nothing hidden away.


    I guess there is also this thread that was started by one of our early beta testers:
    http://forum.unity3d.com/threads/18...ity-(2D-character-controller-problems-solved)
     
    AntonioModer likes this.
  2. Andy-Korth

    Andy-Korth

    Joined:
    Jun 7, 2013
    Posts:
    144
    A teaser gif:
    $animated.gif

    And our kickstarter video:
     
  3. Dabeh

    Dabeh

    Joined:
    Oct 26, 2011
    Posts:
    1,614
  4. Molt

    Molt

    Joined:
    Sep 6, 2011
    Posts:
    103
    Looks interesting, very interesting indeed! I've used Unity's inbuilt physics to power some R&D experiments into UI and hit problems, but this should likely work a lot better. Here, have some money.
     
  5. Burletech

    Burletech

    Joined:
    Jul 1, 2010
    Posts:
    73
    Backed!
     
  6. Andy-Korth

    Andy-Korth

    Joined:
    Jun 7, 2013
    Posts:
    144
  7. soldmeadow

    soldmeadow

    Joined:
    Jun 23, 2011
    Posts:
    42
    Backed.
     
  8. paraself

    paraself

    Joined:
    Jun 30, 2012
    Posts:
    139
    It's really cool. having been looking for a good alternative for physics for a long time. It's definitely what I need.
    Question: is it multi-threaded?
     
  9. Andy-Korth

    Andy-Korth

    Joined:
    Jun 7, 2013
    Posts:
    144
    Yup! We've included both the multithreaded solver and the ARM NEON optimizations. The NEON optimizations use the Advanced SIMD extension to process multiple vector operations in one instruction. Between the two, we get a really nice speed bump.

    A little bit of info about the NEON optimizations: http://howlingmoonsoftware.com/wordpress/chipmunk-pro-goes-neon-19-40-faster/

    The multithreading stuff was introduced back in 2011 as well, but I don't really have a writeup handy about it.
     
  10. sabba2u

    sabba2u

    Joined:
    Feb 3, 2012
    Posts:
    42
    If we support your kickstarter how can we get the asset store version? There is no way to "add" authorized users as far as I could tell from when people wanted to try our assets.
     
  11. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    270
    So we are planning on selling it both through the Asset Store and our own website. That gives us more flexibility to do sales, promotions and such if we need.
     
  12. SRH

    SRH

    Joined:
    Feb 28, 2011
    Posts:
    160
    this looks really interesting... backed
     
  13. Andy-Korth

    Andy-Korth

    Joined:
    Jun 7, 2013
    Posts:
    144
  14. soldmeadow

    soldmeadow

    Joined:
    Jun 23, 2011
    Posts:
    42
    Great news that Unity Pro isn't required. In the Pachinko iPad demo in the video are the balls in the Chipmunk2D version just standard Unity sphere objects? If so is there some automation in Chipmunk2D that will convert sphere rigid bodies to Chipmunk circles?
     
  15. Andy-Korth

    Andy-Korth

    Joined:
    Jun 7, 2013
    Posts:
    144
    In the two Pachinko demos, the spheres are both just the standard Unity spheres. In the Chipmunk version, we replaced the the PhysX sphere and rigidbody with the Chipmunk components.

    We've considered some automation for this process. There are certain things like the basic shapes that can be converted automatically pretty easily. Other things like joints might not have 1:1 analogs between PhysX and Chipmunk and probably couldn't be converted automatically. Our development process is driven by you guys, so let me know if you think some automatic conversion tools would be a priority and we can get on it!
     
  16. soldmeadow

    soldmeadow

    Joined:
    Jun 23, 2011
    Posts:
    42
    @Andy - I'm using 2d Toolkit for sprite based games. 2d Toolkit provides an editor for specifying a collision shape for each sprite frame which gets implemented using PhysX. It would be nice to be able to tweak the collisions in 2d Toolkit and have them picked up by Chipmunk2d with minimal intervention. Once I get the Chipmunk2d beta I'll be investigating how best to integrate it with 2d Toolkit. The ultimate, for me, would be to have Chipmunk2d directly supported in 2d Toolkit.
     
  17. paraself

    paraself

    Joined:
    Jun 30, 2012
    Posts:
    139
    +1 ! It will be a perfect workflow on 2d development!
     
  18. Andy-Korth

    Andy-Korth

    Joined:
    Jun 7, 2013
    Posts:
    144
    Cool, thanks for the info, soldmeadow. I'm not familiar with 2D Toolkit, we've tried a few similar libraries, but I don't remember that one. Tying in to their editor scripts would definitely be cool for the people who are using it. I'll ask a bunch of other people to try to get a sense for what popular sprite engines are, and see if there are enough people to warrant the time looking at this one. Sounds like this could be a good stretch goal!
     
  19. meta87

    meta87

    Joined:
    Dec 31, 2012
    Posts:
    254
    Adding my support for 2d Toolkit! That would be an amazing workflow. Glad to see the kickstarter has reached its goal, congrats! Looking forward to playing around with this :)
     
  20. soldmeadow

    soldmeadow

    Joined:
    Jun 23, 2011
    Posts:
    42
    @Andy - 2d Toolkit has been in the top 10 paid charts for a long time and I would say it is the de facto standard for 2d on Unity. There are some cheaper alternatives but if people are choosing their sprite library based on saving $30 then they are probably not a great target market for Chipmunk2d either. The 2d Toolkit developer knows his stuff - for example, you can search for how various 2d libraries handle pre-multiplied alpha on iOS. The 2d Toolkit developer was the only one I found that knew what he was talking about in that regard.

    In my ideal world some of the integration would be handled in 2d Toolkit. For example, in the sprite collection configuration dialog there could be an option to use built in physics or Chipmunk2d. It may simply be a matter of you guys exchanging a license of Chipmunk2d for a 2d Toolkit license.
     
  21. unikronsoftware

    unikronsoftware

    Joined:
    May 21, 2011
    Posts:
    1,287
    As the developer of 2D Toolkit, I'll definitely be up for doing a little bit of work to get this integrated nicely into the core. We've added a reflection based editor extension system in the animation editor - we could do something similar for the sprite collection editor - we could get some pretty "native" integration without imposing the library to anyone :)

    Drop me an email at support at unikronsoftware dot com if you'd like to have a chat about possibilities.
     
  22. Andy-Korth

    Andy-Korth

    Joined:
    Jun 7, 2013
    Posts:
    144
    Thanks Unikron! Email is on the way!
     
  23. meta87

    meta87

    Joined:
    Dec 31, 2012
    Posts:
    254
    Only a few days left on this everybody! I went with the Pro level on the kickstarter, can't wait to start experimenting with it :D

    I was wondering about a couple of things if you dont mind. Do raycasts work with Chipmunk2d colliders? Or something similar perhaps?

    I read that chipmunk2d pro has automatic polygon collider generation. Will this work within Unity, say on a mesh for example?

    Thanks!
     
  24. soldmeadow

    soldmeadow

    Joined:
    Jun 23, 2011
    Posts:
    42
    @meta87 - yes there is raycasting but it is called a segment query in Chipmunk. It is demonstrated in the Chipmunk demo.
     
  25. meta87

    meta87

    Joined:
    Dec 31, 2012
    Posts:
    254
    Thanks for the info soldmeadow.
     
  26. Andy-Korth

    Andy-Korth

    Joined:
    Jun 7, 2013
    Posts:
    144
    For those interested in the project, we've posted a new update: http://www.kickstarter.com/projects/howlingmoonsoftware/chipmunk2d-for-unity/posts/537423

    This includes a teaser video of one of our tutorials, using Chipmunk2D for Buoyancy effects:


    Meta87: Chipmunk Pro does have some automatic geometry generation tools, but they aren't in our current plan to bring to Unity. A few people have asked, so I will try to add our rationale to the kickstarter FAQ. Short summary is that it isn't a great fit for the Unity pipeline.

    Next up is sending out the beta, which will go out as soon as we have contact information from the survey responses. Thank you all for your support!
     
  27. sean-bradbury

    sean-bradbury

    Joined:
    Jul 13, 2013
    Posts:
    24
    This plus that equals backed for the Pro version. :)
    Glad I found this thread in time.
     
  28. paraself

    paraself

    Joined:
    Jun 30, 2012
    Posts:
    139
    Only one day to go! :p Congratulations!
    I'd like to know if soft body physics is supported? :)
    Thanks for making this awesome tool.
     
  29. Andy-Korth

    Andy-Korth

    Joined:
    Jun 7, 2013
    Posts:
    144
    Thank you all for the support!

    Chipmunk2D is a rigid body physics engine. Some people have implemented soft body stuff in it before (including us http://www.youtube.com/watch?v=McvG32qEoSo ), but it's not something we officially support.

    Here's a quick teaser of how we've implemented infinite procedurally generated terrain in Unity using Chipmunk. In about two pages of code we set up code that adds and removes terrain as you move left and right.

     
  30. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    I am really looking forward for this neat Plugin, all the time I hoped for a decent 2D Physics System in Unity, but neither FarseerUnity nor the NativeBox2D plugin where good solutions. Chipmunk2D for Unity seems to be the best. Can't wait to get my hands on, but I would like to know some things:

    - Exactly how should I think about "making" the game with your physics? I'm working with 2D Toolkit for Sprite- and Animationmanagement.
    Will there be a "CharacterController" in order to move my Character around (for example via mobile Input) ?
    - will there be something like "Triggers" (in my game I'm often working with Boxes which are checked as Triggers in order to...yeah...trigger certain Events)
    - how does the (Physic)Layer-Management work with the Unitylayers?
     
  31. steveR

    steveR

    Joined:
    Jul 14, 2013
    Posts:
    33
    is it possible to add large scale terrain similar to http://www.youtube.com/watch?v=rb49mke8K2k in Unity with Chipmunk? In the video you say "An example project that shows how to do very large scale, realtime deformable terrain with Cocos2D 2.0 and Chipmunk Pro".
     
  32. josemoreira

    josemoreira

    Joined:
    Jul 23, 2012
    Posts:
    35
    I can't believe i missed the kickstarter campaign for a few hours :( :( :(
     
  33. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I'd like to see some kind of list of test results on a given piece of hardware, saying how many objects of a given type were handled at what framerate.
     
  34. paraself

    paraself

    Joined:
    Jun 30, 2012
    Posts:
    139
    +1, and with comparison to build-in PhyX
     
  35. meta87

    meta87

    Joined:
    Dec 31, 2012
    Posts:
    254
    I'll try and toss some numbers up when I get ahold of it soon. I can test it on a Nexus 7 and a few iOS devices.
     
  36. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Mobile results would be useful too but I mainly want to know about desktop.
     
  37. meta87

    meta87

    Joined:
    Dec 31, 2012
    Posts:
    254
    Sure thing, will run it on pc as well.
     
  38. meta87

    meta87

    Joined:
    Dec 31, 2012
    Posts:
    254
    I got the beta earlier today. So far I am extremely impressed. Very nice sample projects and what looks like a very simple to use api. The Unity gizmos to adjust everything is also really nice. I ran some really quick performance tests on my (older) macbook pro. I ran the included performance sample that is shown on the kickstarter video. I had to make a few changes to the code to get the physx test functioning, but it seemed to be a fair test.

    On the physx test, when I got to about 550 rigidbodies (box colliders) the fps plummeted to about 4fps. On the chipmunk test, The fps stayed steady till about 1000 cubes when it dropped to 50 fps. 1350 cubes about 40 fps. 1750 about 20 fps. It really started to bog down after 2100ish.

    Allocations hovered between 0 and 24 bytes no matter how many cubes I added.

    I'll do some more in-depth tests with different shapes. I'm interested to see how performance is with very large polygon colliders for level geometry.
     
  39. josemoreira

    josemoreira

    Joined:
    Jul 23, 2012
    Posts:
    35
    Any news on the Asset Store release date? I want to spend some money in this one :)
    Finally i can leave the awful, horrible and disgusting physx :D
     
  40. mu-kow

    mu-kow

    Joined:
    May 15, 2012
    Posts:
    106
    Hi there,

    I'm interested to hear more about the soft body implementation. You mentioned that it doesn't work out of the box but could be managed. Are you planning on adding support for it in Unity? If you don't, is it possible for the end user to do so? Are you connecting other rigid bodies with springs or are you using a special body meant for the soft bodies?

    Thanks!
     
  41. leissler

    leissler

    Joined:
    Mar 21, 2013
    Posts:
    18
    +1 for Unikron's 2D Toolkit integration. This would be a real dream team! It would make the result an instant look-no-further combo.
     
  42. paraself

    paraself

    Joined:
    Jun 30, 2012
    Posts:
    139
    Hi do you have a estimated date on releasing it in unity asset store? If it's not soon, is it possible to buy license now and access the beta for anyone that missed the kickstarter ?
     
  43. wccrawford

    wccrawford

    Joined:
    Sep 30, 2011
    Posts:
    2,039
    I'm looking forward to seeing this hit the Unity store. I missed the kickstarter and just heard about it now.
     
  44. nab

    nab

    Joined:
    Aug 2, 2013
    Posts:
    8
    +1 for those of us who missed the kickstarter
     
  45. Molt

    Molt

    Joined:
    Sep 6, 2011
    Posts:
    103
    Been playing with this today and so far I'm very impressed, seems easy to use and nicely stable.

    One thing I haven't been able to do thought is breakable joints. I read that on the non-Unity version this could be done by accessing the impulse being applied to the joint and using that to determine whether to break but so far I've not been able to do this in Unity.

    Is there a work-around I'm missing?
     
  46. runonthespot

    runonthespot

    Joined:
    Sep 29, 2010
    Posts:
    305
    The last 5 days have been the longest 2 days of my life ;) Really looking forward to this being generally available.
     
  47. josemoreira

    josemoreira

    Joined:
    Jul 23, 2012
    Posts:
    35
    Any news on the release? Anyone?

    Looking forward to this little asset, but the developers seen to took a vow of silence :(
     
  48. soldmeadow

    soldmeadow

    Joined:
    Jun 23, 2011
    Posts:
    42
  49. josemoreira

    josemoreira

    Joined:
    Jul 23, 2012
    Posts:
    35
    @soldmeadow

    Thanks for the info :)
    I will get it later this day... Cant wait!
     
  50. leissler

    leissler

    Joined:
    Mar 21, 2013
    Posts:
    18
    Any news on the collaboration between Unikron (2D Toolkit) and Chipmunk Physics? In this thread it seems they exchanged e-mails at least.
    Could either Unikron or the Chipmunk side give an update on this?