Physics: change friction bug (updated) and Density

Bugs will be moved here once resolved.

Post » Thu Jan 15, 2015 10:47 pm

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. :D
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,173

Post » Fri Jan 30, 2015 2:48 pm

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.
Scirra Founder
B
402
S
238
G
89
Posts: 24,628
Reputation: 196,023

Post » Sat Jan 31, 2015 1:02 am

I feel like it's Christmas all over again, thanks!
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,173


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 0 guests