Lineardamping - simple bug driving me mad

Hey all,

I’ve added a body to a group and have applied lineardamping, however, the damn thing won’t slow down. Any idea what is going wrong?

local map = require ("com.twothreetwo.display.Map").new() mapScrollView:insert( map ) physics.addBody( map, { density = 1, friction = 0.20, bounce = 0} ) map.isFixedRotation = true map:applyLinearImpulse( 10000, 0, map.x, map.y ) map.linearDamping = 10;

I’ve even tried adding the linearDamping on enterframe but the map body still doesn’t slow down.

Any ideas?

Thanks,

N

Hi @nglenister,

Try swapping the last two lines: establish the damping before you apply the impulse. Sometimes it’s the mere order of how you do things in Box2D.

I assume this “map” is just a normal display object? I don’t know exactly what that module is generating by your code.

Brent

Thanks Brent! It turns out that I was setting the linearDamping before the body was being created (some additional depreciated code that should have been commented out).

If anyone else has this issue just check the ordering of your code, exactly as Brent has suggested.

Hi @nglenister,

Try swapping the last two lines: establish the damping before you apply the impulse. Sometimes it’s the mere order of how you do things in Box2D.

I assume this “map” is just a normal display object? I don’t know exactly what that module is generating by your code.

Brent

Thanks Brent! It turns out that I was setting the linearDamping before the body was being created (some additional depreciated code that should have been commented out).

If anyone else has this issue just check the ordering of your code, exactly as Brent has suggested.