Lengthening / shortening a distance joint?

0 favourites
  • 2 posts
From the Asset Store
This sound library contains 197 rifle sounds. The sounds of gunshots, the sounds of shots from a distance
  • Hello, all! This is my first time posting here asking for help, and I do hope that I'm able to adequately explain my dilemma.

    I've had a game idea kicking around in my head for a while for a platformer game that mainly centers around the use of a "grappling hook" that can affix to any surface, allowing the player to swing around and traverse the landscape. The idea was that the length of the "rope" binding the player to the grappling hook would be set when the anchor hits the wall, and exceeding that length would cause the player to swing.

    I tried creating a distance joint, which allowed for smooth swinging, but behaved unrealistically when the player was above the anchor point, as the bond was supposed to be more reminiscent of a rope than a rigid pole - when firing the grappling hook at the ground, the player should simply fall towards it as normal.

    Next, I tried rigging a "bungee" style system, where the physics would create a force pushing the player towards the anchor when exceeding the bond's length. Unfortunately, while this behaved more accurately for a "rope" style bond, it created erratic swinging patterns that were difficult to control.

    Ultimately, I created a "hybrid" system, where the bond behaves as a distance joint when the player is below the anchor, and a "bungee" bond when the player is above the anchor. Ultimately it worked out pretty well.

    dropbox.com/s/g3bx5iuu1elax3a/GrappleTest.capx

    Here's the testing engine I put together, with some really basic rudimentary controls. A and D move the player left and right, W "jumps", and clicking and holding the mouse button binds the player to the green "anchor" square, allowing them to swing around. While swinging, A and D create slight left and right momentum.

    Now, here's the problem - part of the controls I want for this game include shortening and lengthening the bond while swinging, so that you can grapple ceilings and high walls and then pull yourself up, or safely rappel down into pits. Unfortunately, there doesn't seem to be a way to smoothly lengthen and shorten a distance bond, while keeping the "swinging" motion intact.

    Does anyone have any suggestions? I'm also open to discarding the system I've rigged in favor of another one that would accurately exhibit the behavior I described.

    Thanks in advance for your help!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I just wanted to say that your example is very impressive! Thank you very much for sharing it

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