Physics body default values for friction and bounce

The physics body default values seem to vary depending on the type of body. For example, in the following code I think the circles, the rectangle and the rectangular-shaped polygon all behave differently with respect to bounce and friction:

local physics = require "physics" physics.start() physics.setDrawMode("hybrid") ball = display.newCircle(80, 40, 16) physics.addBody(ball, "dynamic", {radius=16}) ball2 = display.newCircle(240, 40, 16) physics.addBody(ball2, "dynamic", {radius=16}) plank1 = display.newRect(80, 320, 140, 8) physics.addBody(plank1, "static") plank1:rotate(-10) plank2 = display.newRect(240, 320, 140, 8) physics.addBody(plank2, "static", {shape={-70,-4, 70,-4, 70,4, -70,4}}) plank2:rotate(10)

The solution is to explicitly set the defaults on all bodies ({density=1.0, friction=0.3, bounce=0.2}) but it still seems confusing and at odds with the documentation – or am I misunderstanding something?

In the above code I tried to work out the values for friction and bounce that would give the same effect as that which occurs with no values set (so I could work out what the defaults were), but I couldn’t find any values that seemed to fit.

Thanks,

Warwick

Hi Warwick,

I can ask the engineers for clarification, but the defaults should be the same for all. What kind of indications did you see which may prove otherwise?

Best regards,

Brent

G’day Brent,

In the code I posted above, two identical circular bodies fall equal distances on to two identical-looking, slightly sloping rectangles. One rectangle is defined in physics as a rectangular body, and the other as a polygon body, but their actual dimensions and slopes are equal.

What I’d expect from this is that both circular bodies bounce equally, and both have some amount of spin introduced due to the sloping surface they impact.

What happens in practice is that the circular body hitting the rectangular body bounces but does not spin, while the circular body hitting the polygon body neither bounces nor spins, and just slides down the sloping surface as if it has zero friction and bounce.

Having two identical circular bodies hitting two identical-looking surfaces but then responding completely differently seems wrong; and neither behaviour seems to match the documented defaults for bounce and friction.

Cheers,

Warwick

Hi Warwick,

This does seem to be a bug, as my tests reveal the same, both in recent builds and older builds. I’ve asked the engineers to investigate which default values are being applied, and what values those are (if they’re not what we state, which seems to be the case).

Thanks for the report,

Brent

Hi Warwick,

I can ask the engineers for clarification, but the defaults should be the same for all. What kind of indications did you see which may prove otherwise?

Best regards,

Brent

G’day Brent,

In the code I posted above, two identical circular bodies fall equal distances on to two identical-looking, slightly sloping rectangles. One rectangle is defined in physics as a rectangular body, and the other as a polygon body, but their actual dimensions and slopes are equal.

What I’d expect from this is that both circular bodies bounce equally, and both have some amount of spin introduced due to the sloping surface they impact.

What happens in practice is that the circular body hitting the rectangular body bounces but does not spin, while the circular body hitting the polygon body neither bounces nor spins, and just slides down the sloping surface as if it has zero friction and bounce.

Having two identical circular bodies hitting two identical-looking surfaces but then responding completely differently seems wrong; and neither behaviour seems to match the documented defaults for bounce and friction.

Cheers,

Warwick

Hi Warwick,

This does seem to be a bug, as my tests reveal the same, both in recent builds and older builds. I’ve asked the engineers to investigate which default values are being applied, and what values those are (if they’re not what we state, which seems to be the case).

Thanks for the report,

Brent