[Behavior] Box2D+ (asm.js r2.3.0; v2.0)

1 favourites
From the Asset Store
2d mushroom sprite 2d game character enmy sprite game art
  • This is a Box2D behavior based on the Emscripten port at r2.3.0 standard. The plugin gives access to most of Box2D and includes some added helper features to make the dev process easier. The demo can be found here: link

    There main demo has 4 parts:

    1. The start screen gives you an idea of performance and demonstrates one-event conveyor belts with kinematic bodies. Collision points and polygons can be selected to be drawn and objects can be thrown around.

    2. Bitmap / scan image. This is a demo with 2 objects - one fixed and one that will be re-spawned; when running, both types can be dragged. You can use the default images or upload your own into the demo. When you press Start the engine will scan the images and assign collision polygons from the image alpha.

    3. Stress test. A comparison with Chipmunk (which, from my previous testing, is the best non-emscripten physics library in JavaScript) and the standard asm.js physics behavior. The test creates a pyramid of boxes that you can interact with or just watch collapse....

    4. Draw objects. Draw some physics shapes, convex or concave, and watch them fall down. The shape vertices are stored in a c2 array which is loaded into the Box2D+ plugin to form the collision polygon.

    Summary of features:

    Scan image to create polygon from its alpha (uses adjusted versions of hull.js and simplify.js)

    Circle, polygon and box shapes

    Speed clamp

    Rotational speed clamp

    Collision point

    Dynamic, Static and Kinematic bodies

    Collision filtering (category and mask bits)

    Object gravity scale

    World x and y gravity values

    Load collision hull from c2 json array

    Get collision hull as c2 json array (create polygons outside your game and upload from string)

    Raycast world queries

    Assimilate Joint - demo: link

    All joints are demo'd here: link

    AABB world queries (find objects in a defined box area)

    Gravity attractor

    Polygon editor capx (demo: link)

    Instructions!

    More joint helper expressions added

    Obtain collision impulse and collision impulse angle

    Obtain pre-collision and post-collision velocity (x and y values)

    Collision Pre-Solve trigger and an action to disable the collision

    Compatible with Minify export

    Helper plugin, if you want 1 pixel sized vertices (instead of 3 pixels in standard Box2D+) then add this helper plugin to your project: plugin link. Box2d+ will find the plugin and change the world scale.

  • Wow looks great! Nice work!

    Would love to see a performance comparison between this and the regular JavaScript Box2D Construct 2+ uses already, as it would demonstrate why more of the JavaScript should be created from Emscripten/ASM.js

  • Wow looks great! Nice work!

    Would love to see a performance comparison between this and the regular JavaScript Box2D Construct 2+ uses already, as it would demonstrate why more of the JavaScript should be created from Emscripten/ASM.js

    Thanks! This version has similar performance to the asm.js physics, but in my tests it's more stable (see the stress test example that compares all of them). I totally agree, it would be amazing if the runtime was written to compile emscripten...!

  • I bought your behavior, your document write:

    " If both group index values are the same and negative, don't collide" but when I set group index negative (-2) ,Its always return positive (2) and collide. Is it a bug?

    Sorry,I read your document and play with "collision filter" for 5 hours but I can not understand how to combine together "Category bits", "Mask Bits" and "Group index" .Its really hard for me , so Do you have any example capx for "collision filter"? Thank you very much

  • Colludium Awesome, I bought it! Is there any way to make this framerate independent? I use chipmunk atm and the physic simulation goes crazy fast on my 144Hz monitor. Will I have the same problem with this?

  • Colludium Awesome, I bought it! Is there any way to make this framerate independent? I use chipmunk atm and the physic simulation goes crazy fast on my 144Hz monitor. Will I have the same problem with this?

    Awesome . This is already framerate independent (deliberately so because of that very issue). Let me know if you encounter any snags.

  • I bought your behavior, your document write:

    " If both group index values are the same and negative, don't collide" but when I set group index negative (-2) ,Its always return positive (2) and collide. Is it a bug?

    Sorry,I read your document and play with "collision filter" for 5 hours but I can not understand how to combine together "Category bits", "Mask Bits" and "Group index" .Its really hard for me , so Do you have any example capx for "collision filter"? Thank you very much

    Yes, it's a bug (assuming you're referring the editor settings). Hang on for an update!!

    The Mask and Category Bits are complex, until you understand them. They are a decimal number that represents a set of binary bits - if a bit in the Category for Object_A is 1 and the same bit in the Mask for Object_B is 1 then they will collide. The Group Index is used to override these settings for special occasions where you want to alter the collision between two objects. It's a result of how the Box2D library is written - in code, you can use variables to assign Mask and Category bit values and the Group Index allows you to override that variable's value. This iforce2d tutorial might help - it goes into great detail of how it works. I'll try and put together a capx example that should help.

  • Updated to v 1.01

    Bug fixes:

    Minor changes to editor text

    Group Index now can be set to negative values (d'oh!).

    No breaking changes.

    Please re-download from the store to update.

  • gameba - I forgot to add - there is an Action that allows you to enter the Category and Mask Bits as strings.

    Update to v 1.02

    Corrected string entry in Actions: Bits-Category string and Bits-Mask string. Enter the 16 flags as a string of 1's and 0's - it's easier to visualise.

  • gameba - I forgot to add - there is an Action that allows you to enter the Category and Mask Bits as strings.

    Update to v 1.02

    Corrected string entry in Actions: Bits-Category string and Bits-Mask string. Enter the 16 flags as a string of 1's and 0's - it's easier to visualise.

    Thank you, now I understand Bits

    Can you share me capx demo here http://box2dassimilatedemo01.bitballoon.com/ ? I want to understand "Assimilate joint"

    I created 2 capx to test here:

    test BOX2D+ capx here: https://drive.google.com/file/d/16A-TPX ... p=sharinag

    test PHYSICS capx here: https://drive.google.com/file/d/17JQcRP ... sp=sharing

    I tried to set higher value at Action "position Iteration(3000 or more)","velocity Iteration(8000 or more)" but the sprites move inaccurate. I test with Physics behavior of C2, Its move accurate, rigid. Is it a bug?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Corrected string entry in Actions: Bits-Category string and Bits-Mask string. Enter the 16 flags as a string of 1's and 0's - it's easier to visualise.

    Thank you, now I understand Bits

    Can you share me capx demo here http://box2dassimilatedemo01.bitballoon.com/ ? I want to understand "Assimilate joint"

    I created 2 capx to test here:

    test BOX2D+ capx here: https://drive.google.com/file/d/16A-TPX ... p=sharinag

    test PHYSICS capx here: https://drive.google.com/file/d/17JQcRP ... sp=sharing

    I tried to set higher value at Action "position Iteration(3000 or more)","velocity Iteration(8000 or more)" but the sprites move inaccurate. I test with Physics behavior of C2, Its move accurate, rigid. Is it a bug?

    Good re: collision filtering.

    Velcocity iterations default is 12 and Position iterations default is 8. Setting these numbers so high will possibly cause jank in complex collision situations as the engine resolves floating point values to no visible effect, I expect. It won't make any joints more solid, unfortunately.

    The weld joint in Box2D+ is good for attaching 2 or 3 objects together, not long chains of objects. The standard physics engine appears more stable using limited revolute joints. I will provide an example of assimilate joint use later today (I need to recreate the demo capx, so give me a little time).

  • gameba,

    I have added an assimilate joint demo to the examples.zip. Please download to view an example of how to use the joint.

  • > Colludium Awesome, I bought it! Is there any way to make this framerate independent? I use chipmunk atm and the physic simulation goes crazy fast on my 144Hz monitor. Will I have the same problem with this?

    >

    Awesome . This is already framerate independent (deliberately so because of that very issue). Let me know if you encounter any snags.

    Thank you, I'll try replacing my chipmunk events with this and see how it goes

  • Bug fix version 1.03 now available. Fixes:

    • Hotspot offset error when assimilating objects with polygon shape selected.
    • A 'feature' of the Box2D+ library is that weld joints cannot be created on dynamic objects that have prevent rotation selected. I have no idea why... Work around implimented - if you action a weld joint on such an object then the plugin creates a limited revolute joint instead. You should not notice a difference.
  • Bug fix version 1.03 now available. Fixes:

    • Hotspot offset error when assimilating objects with polygon shape selected.
    • A 'feature' of the Box2D+ library is that weld joints cannot be created on dynamic objects that have prevent rotation selected. I have no idea why... Work around implimented - if you action a weld joint on such an object then the plugin creates a limited revolute joint instead. You should not notice a difference.

    good job, I really like Box2d+ behaviou, Its very useful. Thank you

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)