0
\$\begingroup\$

I'm trying to get the physics of a retractable object in unity, So I will be able to "launch" an elastic cable (similar to rope physics) out of an object (e.g. A gun), And the cable will gradually/exponentially "roll back" into the object. A good reference would be Batman's grapple gun.

I thought of utilizing it using a spring joint, but I can't really get the exact mechanics I'm trying to achieve.

Any ideas?

Thank you in advance.

\$\endgroup\$
6
  • \$\begingroup\$ These mechanics usually are not implemented as a retractable physics object per se - that's just the fictional skin with which they're presented to the player. Under the hood we might have a whole chain of separate objects, or no objects at all, just some vectors representing forces or points of contact. They're implemented in lots of different ways depending on the specific needs of the game they're serving, so to get good answers, it would help to walk through a specific use case in your game, and how the behaviour you've gotten so far with a spring joint differs from what you need. \$\endgroup\$
    – DMGregory
    Oct 11, 2020 at 20:28
  • \$\begingroup\$ I understand your point. I meant creating the physical manipulation to make it behave similarly to a retractable object. In my game, there are two characters, each one of them has a gun he can shoot. When pressing the shot button, a cable jumps from the tip of the gun, if the cable collides with the other player, the cable sticks to the other player and reducing his HP. If the cable didn't collide with the other player, it's "rolling back" into the gun. With the spring joint, the cable swings around, isn't returning directly into the gun and does not return to the exact desired position. \$\endgroup\$ Oct 11, 2020 at 21:14
  • \$\begingroup\$ Does the cable end need to interact with other physics objects besides the players? Does the "cable" need to wrap and pull around corners? \$\endgroup\$
    – DMGregory
    Oct 11, 2020 at 21:22
  • \$\begingroup\$ The cable indeed needs to interact with other physics objects such as the ground layer. It does not need to wrap and pull around corners. \$\endgroup\$ Oct 11, 2020 at 21:38
  • \$\begingroup\$ Your ground is a physics object?? \$\endgroup\$
    – Weckar E.
    Oct 12, 2020 at 6:55

0

You must log in to answer this question.

Browse other questions tagged .