+3 votes

I'm trying to implement a grapple gun with a physical rope and a weighted grappler. The idea is that the grappler hook will get stuck on the edge of a rigid cliff and allow you to winch the rope up to the top of it. Seems doable, right? Just create a bunch of small RigidBody2D objects, link them together with a PinJoint2D, link the gun to the beginning and the hook to the end and you're done!

In practice, though, Godot REALLY doesn't like tension in any direction on PinJoints. So if the grapple hook gets stuck on something and I put even a little tension on it, the rope gets sent to the shadow realm. This is especially frustrating if your player character is a KinematicBody2D.

MY QUESTIONS: If I were to make a grapple hook with a physical rope, How do I...
1) properly make the rope appear to shoot out of the grapple gun?
2) Keep tension on the PinJoint2Ds to a minimum so that the rope doesn't yeet itself out of existence? (ie progressively impede the Player from moving away from the rope if it's too tight.)

Thanks in advance for the help!

Godot version 3.3
in Engine by (24 points)

1 Answer

0 votes

This might not work, but since this question doesn't have any answers, here's my best shot:

  1. Get the distance from the player to the end of the grappling hook.
  2. If distance > length of rope, get the direction vector D from the player to the hook. Multiply D by (rope length - distance). Then subtract that from the player's velocity.

Alternatively you could try getting the direction vector from the player to the first segment in the rope. If so, then you would have to check if distance > [maximum allowed distance between player and first segment].

by (16 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.