0 Favourites

Creating my own physics behavior, need info

  • Hi,

    I don't know anything about behavior development.

    I need to create a copy of the default physics behavior with my own settings (just lowering b2_velocityThreshold actually)

    What's the difference between runtime.js and runtime-ams.js in this directory? The behavior seems not to be using runtime.js as deleting this file won't cause the behavior to crash.

    Plus, runtime-ams.js is twice runtime.js size though it contains some sort of minified javascript.

    If I replace runtime-ams.js content with runtime.js content, the behavior seems still working though the file is half the original size.

    Can you explain me what's going on here?

    What would be the best method in order to make my own copy of this behavior?

  • Typically there is only a runtime and edittime js. The physics behavior Is special case. One is just a JavaScript port of box2d and one is one compiled with asm.js. It's bigger but will run near native c++ performance. You can select between the two in the project properties.

    If you were to copy the behavior just pick either file to be your runtime.

  • Thank you very much for this explanation.

    So I guess the simplest way is to duplicate the physics behavior?

    There is no way to edit this b2_velocityThreshold value inside C2 via a custom plugin or something like that?

    The things that bother me is that I'll have to add my new custom physics behavior to all my objects and then edit all my conditions and events referring to the physics behavior to replace them with the other behavior conditions & events.

  • You could just edit in in place if it's something just you would use. If you want to change it per project the best thing would be to add an action to the plugin. That would give the easiest access to the setting.

    I guess it may be possible to change the setting with some JavaScript run with the browser object. That can be hard though, mainly to track down a code path to access it. It would also not work if you minified your project.

  • If you use "box2d web" instead of "box2d asm.js" you can use the browser object to run:

    "Box2D.Common.b2Settings.b2_velocityThreshold = 1.0;"

    and set it to whatever value you want. The asm.js version seems to not have that variable. This won't work after minifying.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Thanks again for these useful information

    Since my game won't use a lot of physical objects, I guess I can stick to box2d web.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
1,941 263,199
FlyingRam's avatar
FlyingRam
Unread hot topic
0 Favourites
[BEHAVIOR] Chipmunk Physics
673 82,473
nelostic's avatar
nelostic
Unread hot topic
0 Favourites
[Behavior] LiteTween
672 169,837
manujorgo's avatar
manujorgo