# Logic to attach two objects via a rope

**URL:** <https://discourse.threejs.org/t/logic-to-attach-two-objects-via-a-rope/37614>\
**Category:** Questions\
**Tags:** mesh, math\
**Created:** [April 29, 2022, 7:55am UTC](https://discourse.threejs.org/t/logic-to-attach-two-objects-via-a-rope/37614 "2022-04-29T07:55:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Liron\_Toledo](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/liron_toledo/32/19894_2.png) [@Liron\_Toledo](https://discourse.threejs.org/u/Liron_Toledo)\
**Post date:** [April 29, 2022, 7:55am UTC](https://discourse.threejs.org/t/logic-to-attach-two-objects-via-a-rope/37614/1 "2022-04-29T07:55:08Z")

</div>

Hi all! I had an idea that i wanted to try implement in my app but not sure about the best way to go about it. I want to try and connect one object (lets call it A) to another object (lets call it B) by an invisible rope. A should then be able to drag B behind it. Both these objects have collision and B despite being dragged can also move around so if B were to get stuck or try and move away from A the rope should snap and the objects will be independent again. Ideally I’d like to avoid using actual physics in favour of a purely logic/mathematical approach. Problem is I kinda suck at math 😅 I’m going to continue to crack at it myself but would appreciate any help or advice you can provide. Thanks!

Edit: Decided to add a crude drawing of what I described above 🙂

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/4/9/492462273bc11156e553b9462c75d5c414e33e19.jpeg)

---

<div class="post-metadata">

**Author:** ![JuanP](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/juanp/32/25869_2.png) [@JuanP](https://discourse.threejs.org/u/JuanP)\
**Post date:** [April 29, 2022, 8:44am UTC](https://discourse.threejs.org/t/logic-to-attach-two-objects-via-a-rope/37614/2 "2022-04-29T08:44:19Z")

</div>

Probably you will need a physics helpers

Take a look at this post [Recommended Physics Engine?](https://discourse.threejs.org/t/recommended-physics-engine/16214)

---

<div class="post-metadata">

**Author:** ![Liron\_Toledo](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/liron_toledo/32/19894_2.png) [@Liron\_Toledo](https://discourse.threejs.org/u/Liron_Toledo)\
**Post date:** [April 29, 2022, 9:02am UTC](https://discourse.threejs.org/t/logic-to-attach-two-objects-via-a-rope/37614/3 "2022-04-29T09:02:42Z")

</div>

@JuanP Do you rate using a physics engine is the only way? Was aiming to avoid that if possible.

---

<div class="post-metadata">

**Author:** ![drcmda](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@drcmda](https://discourse.threejs.org/u/drcmda)\
**Post date:** [April 29, 2022, 9:29am UTC](https://discourse.threejs.org/t/logic-to-attach-two-objects-via-a-rope/37614/4 "2022-04-29T09:29:41Z")

</div>

i made something like this and abstracted it into a component: [Backdrop and cables - CodeSandbox](https://codesandbox.io/s/backdrop-and-cables-2ij9u) the QuadraticBezierLine component still looks dodgy, not really a rope but gsimone made a better one that’s finished but not merged yet: [things/README.md at main · gsimone/things · GitHub](https://github.com/gsimone/things/blob/main/README.md#catenary-curve)

![catenary](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/c/2/c22841bf3287aea496f37328b1306ee9fe4d1a26.gif)

as for snapping, you need something like cannon (physics). i only found a chain example, though that one doesn’t snap [use-cannon/demo-Chain.tsx at 90dfc122945877b91f8d58700e3363e828a52d1b · pmndrs/use-cannon · GitHub](https://github.com/pmndrs/use-cannon/blob/90dfc122945877b91f8d58700e3363e828a52d1b/packages/react-three-cannon-examples/src/demos/demo-Chain.tsx)

---

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [July 3, 2023, 9:48pm UTC](https://discourse.threejs.org/t/logic-to-attach-two-objects-via-a-rope/37614/5 "2023-07-03T21:48:48Z")

</div>

I like that CatenaryCurve 🙂

[https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/1/2/129d6e3a33779ebc1d85d561ccb91f23d86199b6.mp4](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/1/2/129d6e3a33779ebc1d85d561ccb91f23d86199b6.mp4)

---

<div class="post-metadata">

**Author:** ![strandqviststudio](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@strandqviststudio](https://discourse.threejs.org/u/strandqviststudio)\
**Post date:** [July 28, 2023, 3:33pm UTC](https://discourse.threejs.org/t/logic-to-attach-two-objects-via-a-rope/37614/6 "2023-07-28T15:33:39Z")

</div>

Wow! Looks amazing. Would love to know how you created that chain, Would it be possible to see a demo?

Thx

---

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [July 30, 2023, 1:09pm UTC](https://discourse.threejs.org/t/logic-to-attach-two-objects-via-a-rope/37614/7 "2023-07-30T13:09:39Z")

</div>

> [@strandqviststudio](#):
>
> Would it be possible to see a demo?

I’ll create a topic later 🙂
