[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
  • Colludium

    is it possible to set collision category&mask bits for object instances individually?

    or only object types?

    Hi. Yes, collision filtering settings are defined per instance.

  • Colludium Your physics behaviour fixes the default physics behaviour problem on creating/destroying lots of instances?

    This error: https://i.imgur.com/H126akC.png

    I was using the physic behaviour on tilemap for pixel destruction but had to change for Chipmunk physics due this error, that seems is a know bug of this behaviour.

    ---

    One of the things i was looking to do is some kind of destruction like the next gif one. I saw your samples on you draw a polygon and this one falls with physics,etc... your physics behaviour can do that? or there is any kind of helper like the platform Box2D+ but for destruction? .

  • Hi matriax,

    [quote:20j95b4e]Your physics behaviour fixes the default physics behaviour problem on creating/destroying lots of instances?

    I imagine that if you spawn a huge number of objects then you could run into memory problems. However, I just tested a spawn of 1000 circle shapes and there was no problem on my poor old laptop. I don't know what caused that error you showed in the standard Physics plugin - the Box2D+ is more a up-to-date version of Box2D, but it may well carry the same limitation.

    [quote:20j95b4e]I saw your samples on you draw a polygon and this one falls with physics,etc... your physics behaviour can do that? or there is any kind of helper like the platform Box2D+ but for destruction?

    Box2D+ allows you to change the collision shape at runtime to anything you want. You just define the shape in an array object (vertices as fractional values of width/height to describe points measured from the midpoint - ie, a bottom right corner would be [0.5, 0.5]) and then load it into the object as an array.AsJSON; the plugin does the rest. You can have any polygon shape you want as long as it's simple (no crossing edges, or the plugin will give you a box shape), convex or concave are supported of course. It's not magic - but I like to think it's a helpful port of Box2D . The demo I created used Canvas objects to draw the shapes with the same vertices loaded into the Box2D+ plugin to assign the shape in the behavior. The plugin has an acceptable shape check and that was used in the demo to stop the drawing if the shape was about to become complex.

  • I'm using a Tilemap with 1x1 tiles to achieve pixel-perfect destruction. Also i use canvas to read the alpha from sprites and set the tiles on tilemap only on tilesets with 0 alpha.

    I read the info in your page that says:

    [quote:2m6jdq55] If you do use a tilemap, please try not to make lots of in-game changes to the tiles – each time you do the plugin destroys all of the fixtures and then recreates them for the whole tilemap (which might cause jank if the tilemap is large).

    Maybe this is what i mean. Using solids/chipmunk on tilemap i can erase perfectly a 1280x720 tilemap full of destructible objects, but using Box2D at around 30-40% crashes and shows that error.

    This is a video of the prototype:

    Subscribe to Construct videos now

    Any chance to send you the .capx and in your side add your Box2D+ plugin to the tilemap and test if erasing all the destructible objects works or crashes in the same way?

  • matriax, feel free to pm me a link - as long as it's not too complex then I'll be able to take a look today .

  • Well, just bought.

    The first thing is that i had to erase all the physics behaviours on the project and then i added the Box2D+ behaviour to the TileMap Family and i got this error:

    Also tried to open a new blank project and still the same error message. Nor works on tilemaps for object or family. Tried to change for static, dyanmic and other values and same problem.

    Tried with sprites and works perfect.

    EDIT: Found the bug, with tilemaps with 1x1 pixels to 7x7 pixels not works, for 8x8 pixel size to up works(I mean the Tile Width/height). Can you fix it?

    EDIT2: Tried with my project and only works with tile width/height to 64x64 , mmm i dont know what is happening :S . Seems only works when there is no tiles on tilemap. In the moment you set at least one tile then the error appears.

    ---

    Also is possible that you include the .capx of the demo with all the tests? The one with polygons, comparision, drawing objects,etc... ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Update: v 1.13

    Bugfix: type-o in the runtime.js file. Please re-upload to get the latest version.

  • matriax,

    Thanks for the bug report - apologies for you finding it immediately upon purchase. The plugin supports a minimum vertex length of 2.5 pixels - I hadn't anticipated anyone using a tilemap where each tile is 1 pixel long (if I understand you correctly). It is highly likely that the engine will not support such a small tile size. Please let me know if this is going to be a problem for you and I'll try to help any way I can.

    Edit: I have tested the minimum tile size - the minimum size that is supported is 3 pixels (assuming a box collision shape per tile).

  • Colludium Hi, well i need 1x1 pixel in tilemap(With polygon collision) for perfect destruction and colliders. 2.5 means that in real they will need to be 3x3 minimun if i understand you well.

    The physics default behaviour can handle tilemap 1x1, why the Box2D+ that in theory is an improved version can't ¿? . Yes, at some point appears that error in previous post but can manage them at start, maybe porting some function from there to here?

    Also, please, can you add the demo .capx to the files? Will be great to play around with the different demos to see how all works.

  • matriax, the minimum size is a 'feature' of the r2.3.0 Box2D library I used - there is nothing directly that I can do to affect it.

    What I can do is provide you with a method of changing the default world scale. It is currently a hidden value (0.02 - same as for standard Physics). If it is changed to 0.1 then the plugin will support 1 pixel tilemaps (I just tested it and it works ok). If the number is set too high then the plugin library's collisions become visible (objects that should be at rest appear to jostle and move around). Of course, the world gravity will have to be changed as well. Would this suit your needs - it'll take me a few minutes to add a method to do this and then upload?

    Edit - I will create another draw example (the one in the demo broke because of changes to the plugin).

  • Colludium If allows tilemaps of 1x1 yes please. As using Box2D+ i will have to change all the physics system no problem about the changed gravity or others.

    Edit: Ok, specially i want to see the draw demo and the physics comparision Box2d/chipmunk/asm to test all options before add one or other.

    Also seems chipmunk and Box2D+ are compatibles to use in the same project right?

  • matriax - already on it. I will give a World global setting Action to choose between Default (0.02 scale) and Large (0.1 scale). Should take 20 mins.

  • matriax,

    I am sorry, the modification I tried to make would require you to restart the layout once the world scale setting has been changed - it is not possible to implement the change I want to make to the engine via events. The problem is caused by the way the plugin starts inside c2/c3 - the world is created before any events take place, and changing the world scale after the world has been created would cause all sorts of other problems.

    Short term solution: you can change the setting in the plugin yourself using Visual Studio Code / Notepad++ etc. Search for:

    this.data.worldScale = 0.02;[/code:3je73aih]
    
    Then replace [code:3je73aih]0.02[/code:3je73aih] with [code:3je73aih]0.1[/code:3je73aih]
    
    Long term (hopefully later today...) I will try to make a helper plugin that, if loaded inside the project, the Box2D+ plugin will change the world scale.
  • Update v 1.14

    Minor bug fix in collision trigger function

    Added ability to use helper plugin to set the world scale to Large (0.10 instead of 0.02). matriax - I hope this helps

    Helper plugin can be downloaded from here. Just add it to your project somewhere and the Box2D+ plugin will set the Large world scale value.

  • Thanks! now i can add the box2d+ to tilemaps of 1x1. Erased the entire map without problems at the moment, have to test it better.

    Found another bug

    Is just adding the Box2D+ Platform behaviour to my player sprite.

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