0 Favourites

Physics: change friction bug (updated) and Density

  • Problem Description

    If you change an objects friction via action in the event sheet, and the new friction is different than what it was and it is not 0, the object will freeze position for 1 frame following the change. The position is not updated but velocity and forces are still calculated. The object can be frozen in place via friction changes indefinitely. If any force is being added to the object over time, the moment friction stops being changed, the flies as though it has been in movement the whole time.

    ***Edit - Changing density also causes the same problem! - more on this below /edit***

    The one frame freeze is noticeable at 60fps and extremely noticeable at 40 fps

    Using either box2d web or ams.js makes no difference.

    Attach a Capx

    https://dl.dropboxusercontent.com/u/114 ... oblem.capx

    Description of Capx

    This capx is running a physics simulation with friction set to 0 by default. The ball should bounce around forever as there is no damping and elasticity is set to 100%

    Any frame in which you are pressing space key, the ball object will have its friction set to random(0,1).

    Notice the freeze.

    Steps to Reproduce Bug

    • Step 1 - make a physics object
    • Step 2 - change its friction to a different number than what it was and not 0

    Observed Result

    Objects freeze when changing friction

    Expected Result

    The object should not freeze... >.>

    Affected Browsers

      ALL

    Operating System and Service Pack

    Windows 7 service pack 1, windows 7, windows 8

    Construct 2 Version ID

    190 64 bit and previous versions (I have been aware of the problem since June 2014)

    This bug makes it unreasonable to change friction at runtime in the best of situations. I have checked box2d forums and could not tell if it was a problem with box2d or contruct2 (my hunch is that it is box2d... but I really can't say.

    ***EDIT***

    My hunch is that it is the behavior to blame. It looks like the body is being recreated after setting this.friction. it could be that recreating the body induces a one frame penalty given the way everything updates. Also, Box2d has a built in SetFriction that should be called here, if I am not mistaken. I think you also have to update contacts that are already occurring between the object being changed. Box2d stores the friction in the contact and does not regenerate that information on continued contacts. <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

  • Should be fixed in the next build, but only in the asm.js version. We hope to be phasing out the other physics engine soon after.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • I feel like it's Christmas all over again, thanks!

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