Rope joint?

0 favourites
  • 7 posts
  • Hey!

    I wanted to create so to say rope (Not like those chains, that linked together, which have tons of tutorials on youtube), using Physics behaviour. Basically it should be a distance joint between two objects, which activates only when the distance between these objects equals the max length of the rope. So it should not limit any of these objects' movement until the rope gets fully streched. I tried creating a prismatic joint, but it limits objects' movement within one angle.

    It should be something like in this game teamdisgrace.itch.io/bob-flop

    Tagged:

  • The physics behavior doesn’t provide that joint.

    A few ideas come to mind though.

    1. Is to do event based physics using verlet. I’ve made rope examples that do that. It’s as simple as if the distance is greater than a certain amount the objects are moved toward each other to correct that, then the velocities are updated. The cons are it’s independent of the physics behavior and working with ridged bodies will require more code.

    2. Joints in the physics engine are done with impulses behind the scene so in theory you could make the joint you want with that. I fiddled with the idea a bit and something like an impulse of (distance-100)/100 toward the other object seems to work but is bouncy. For better results we could copy what impulses box2d calculates for such a joint.

    Edit:

    If d is the distance between the objects and ang is the angle between them, then the impulse should be the following when dist<100. At least from what I’ve read.

    ImpulseAtoB= -(d-100+(A.vx-B.vx)*cos(ang)+(A.xy-B.vy)*sin(ang))/(1/A.mass+1/B.mass)

    I’ll test this later. The units may be off.

  • Here’s the rope joint done with impulses. 100 is the max distance. The /100 at the end was to scale things down.

    dropbox.com/s/bpxf1z9zws5e1t8/Ropejoint.c3p

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Here’s the rope joint done with impulses. 100 is the max distance. The /100 at the end was to scale things down.

    https://www.dropbox.com/s/bpxf1z9zws5e1t8/Ropejoint.c3p?dl=1

    Yes, exactly what i needed! Works perfect for me, thank you.

  • Here’s the rope joint done with impulses. 100 is the max distance. The /100 at the end was to scale things down.

    https://www.dropbox.com/s/bpxf1z9zws5e1t8/Ropejoint.c3p?dl=1

    Hey! Thank you again - i'm currently using this in my project.

    However, there's one small issue. When i slowly change the rope length during runtime, it strikes one of the charachters with a strong impulse, instead of giving it a gentle pull (ulike in the game i've sent before, where you can change rope length with Q & E).

    Maybe you could help me out with this too? Thank you so much again!

  • I can’t wrap my head around a solution to that. As is the impulse corrects the position but as the length is changing the velocities would have to be updated somehow.

    I tried gradually changing the length with a force but haven’t had much success.

  • Quick update!

    In case anyone is reading this in the future, ima give you heads up.

    I can't believe that the best solution for this was THAT simple. Just create distance joint once the max rope length is reached. When distance between objects is less than max rope length, delete the joint. It's that easy.

    EDIT: Don't forget to increase spring frequency of the rope or else it wouldn't work! (pic 2)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)