Contracting rope

Does anyone have a good way of creating a rope-like physics object which can get shorter?

I don’t mean a piece of elastic, but a string which can be set to shrink and drag anything connected as it does so.

Hi Matt,

I can only make a “best guess” on this, but my approach would be like our “Chains” example, but instead of pivot joints, attach each segment with a “distance” joint, and set the properties of each joint to have a slight flex and elasticity, so the chain could contract and expand slightly.

Of course, that might not prevent the rope from expanding further and further in length (and not return to its original length). If it keeps stretching, you might consider also attaching each segment with a “rope” joint with a maximum distance of some amount to prevent over-stretching.

Best regards,

Brent

Figured it out:

local function shorten( a, b, joint, delay, to, by, time, callback ) local len = to if (by and by \>= 10) then len = j.length - by end local aSleep, bSleep = a.isSleepingAllowed, b.isSleepingAllowed local function onStart(obj) a.isAwake = true b.isAwake = true a.isSleepingAllowed, b.isSleepingAllowed = false, false end local function onComplete(obj) a.isSleepingAllowed, b.isSleepingAllowed = aSleep, bSleep if (callback) then callback(obj) end end transition.to( joint, { delay=delay or 0, time=time or 0, length=len, onStart=onStart, onComplete=onComplete } ) end

Hi Matt,

I can only make a “best guess” on this, but my approach would be like our “Chains” example, but instead of pivot joints, attach each segment with a “distance” joint, and set the properties of each joint to have a slight flex and elasticity, so the chain could contract and expand slightly.

Of course, that might not prevent the rope from expanding further and further in length (and not return to its original length). If it keeps stretching, you might consider also attaching each segment with a “rope” joint with a maximum distance of some amount to prevent over-stretching.

Best regards,

Brent

Figured it out:

local function shorten( a, b, joint, delay, to, by, time, callback ) local len = to if (by and by \>= 10) then len = j.length - by end local aSleep, bSleep = a.isSleepingAllowed, b.isSleepingAllowed local function onStart(obj) a.isAwake = true b.isAwake = true a.isSleepingAllowed, b.isSleepingAllowed = false, false end local function onComplete(obj) a.isSleepingAllowed, b.isSleepingAllowed = aSleep, bSleep if (callback) then callback(obj) end end transition.to( joint, { delay=delay or 0, time=time or 0, length=len, onStart=onStart, onComplete=onComplete } ) end