How do I make a physics rope less buggy?

0 favourites
  • 5 posts
From the Asset Store
characters sprites for creating a 2D action platformer or sidescroller game with cute, kawaii, fantasy theme
  • I am making a rope swing/web swing game, think Indiana Jones or Spiderman. I'm using physics to create a rope (out of small rectangles that are chained together with revolute joints) when I click.

    When I'm swinging underneath platforms like you would expect Spiderman to do, everything is fine: the rope latches on to the platform and you swing in an arc underneath. However, when I connect my rope to a platform below the player character, there is a chance that it will just bug out and elongate forever, twitching and freaking out until I cancel it. Here is a video of what is going on:

    Subscribe to Construct videos now

    And here is the example project which is as bare-bones as I can get it:

    drive.google.com/file/d/1WCHxJhtm2usR0yjLsjDeNqAtwxreinag/view

    How can I make it so that the joints don't freak out? Any help with this would be appreciated. Thanks!

    Tagged:

  • Or should I open a bug report about this?

  • You can try increasing the iterations to try to help the solver not explode like that (there’s a physics action for that).

    Another thing you could try is a distance joint from the first link to the last to help it from not getting too long. This is a general box2d idea, not sure if that shakes out in construct.

    Another idea is since box2d resolves joints with changing the velocity you could try adding some damping on the chain link objects.

    Final thought as to why the chain explodes is when the physics object gets updated. The loop is basically behaviors->events->draw->next frame. Any changes to the physics objects happens at the behaviors step. So maybe the lurch is from the links being in different orientations when the joints are added.

    What I did once to correct that is to create the links, wait till next frame (after the behavior runs again), then add the joints. Or something like that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could also try making the rope out of individual pixels spaced apart but joined with distance joints. You can then adjust the frequency and damping of these joints - at extreme values, you can get all sorts of weird behavior, so you'll need to experiment. Unfortunately, distance joints are invisible - so what I've done is drawn between the pixels using a drawing canvas that I clear every tick.

  • Another thing you could try is a distance joint from the first link to the last to help it from not getting too long. This is a general box2d idea, not sure if that shakes out in construct.

    At first I tried changing all the revolute joints to distance joints but it became super stretchy and wacky and required a ton of experimentation, so I went back to all revolute joints. However, I took your advice and added one distance joint between the first and the last link and that helped tremendously! I have yet to get the rope stretching bug again after a bunch of attempts, knock on wood. It also makes the rope a lot more "snappy" and together than it was before and makes swinging a lot easier.

    Thank you for your help!

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