Physics JavaScript Error

0 favourites
  • 12 posts
From the Asset Store
7 Errors
$15 USD
7 Errors is a game where you have to find the 7 mistakes before time runs out. Can you find all 7? Have fun looking.
  • I am making a pendulum game in construct 2 that involves physics behaviour. I got an runtime javascript abort() error in physics_behavior.js file, when I press release button on the first layout. I checked browser console but I can't figure out what is causing the layout to generate runtime error. I am attaching the link for the errors. Here are the links: https://imgur.com/u51ACQD and https://imgur.com/HoPGkgX

    Here is the .capx file: https://drive.google.com/open?id=1Ro_oz ... w77t4GCRq7

    You can run the game at your side, by following the text that is on the bottom left side of the layout.

    Any solution would be highly appreciated.

    Thanks

  • I think it's caused by a bug in the asm.js library - if you change to box2d web then the problem doesn't happen. The error actually occurs when you go to screen 3, which makes no sense because up until then the box2d world appears stable.

    Of note (Screen 2 event sheet, line 2) you should avoid changing the angle of physics objects by direct events (and not through physics actions) because it can cause 'upset' to the plugin - c2 interprets such changes as velocities, which might have an unexpected effect in the box2d world. Also, line 14 uses "is touching" which will fire all of those subsequent actions every tick - so a 1/2 sec press of the release button could create 30 distance joints...

  • I changed physics from box2d asm.js to box2d web but the error remains the same.

    Can you please explain what do you mean by 'avoid changing angle of physics by direct events' ? I mean how can I do that ?

  • Mmm -the error does not happen for me when I use box2d web...

    If you move a physics object or set its angle directly using the same actions that you would use for a normal sprite, then the physics plugin interprets those changes as requiring a velocity inside the plugin (so, if you moved an object by 5 pixels to the right, the plugin would interpret that as a new velocity of 5 pixels / sec - even though it was 5 pixels in one tick, which would be 300 pixels / sec).

    I was mistaken about the rotational velocity - I thought it also added a rotational velocity component but it does not... Moving objects that way should not really cause any problems in theory, but box2d doesn't always behave well when objects are continuously teleported to a new position or rotation, as would happen when you set the position / angle every tick.

    In your case I would recommend making the pendulum static (immovable) and then you can place it / rotate it once and it won't move. Then, when you want it to fall, make it dynamic (not immovable) and then create the distance joint.

  • I don't want to make the pendulum static (immovable). In that case, how can I achieve the to and fro motion ?

  • Here's a capx that uses Immovable for you - it has the same appearance as your version but the bug is no longer apparent . I've also changed the "is touching" to "on touched" for the relevant conditions.

  • The error is still there. The error shows when interacting with 'a' sprite. For 'b' and 'c' sprites, it works ok.

    I have seen the changes in the capx file (immovable and "on touched") and tested it on Chrome v63.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry, there's nothing more I can do if I can't reproduce the problem myself.

  • I think the problem is with revolution joints. Looks like you need to remove all joints before disabling Physics on pendulums object.

    Also, Colludium is right - you should avoid changing angle or position of pendulums when physics is enabled! This applies to Drag and Drop behavior too.

    So if you want to do this properly, "On Drag start" you should remove joints and disable Physics.

    "On Touched Release button" re-enable physics and re-create the joint.

    Another option - delete Drag&Drop behavior and drag the "pendulums" using impulses or forces.

    Like in that demo I made for your previous post:

  • dop2000, I removed all joints before disabling Physics but the error remains there.

    I don't want the drag and drop behaviour to the pendulum.

  • I removed the joints and the error is gone:

    https://www.dropbox.com/s/yexryny2lddkv ... .capx?dl=0

  • dop2000, Thanks,

    Now, it works without errors.

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