Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rope pulling problem
#1
Hello!
First thing love the asset.
Im trying to make "Spider-man web".
Im shooting a rigidbody that a rope is attached to and making it longer cursor.ChangeLength() until it reaches a wall.
When it does I "lock" the length and then the player (which is attached to the other side of the rope) gets a massive velocity change towards the shot rigidbody.
Anyway to cancel out this velocity?
Thanks
Reply
#2
(29-08-2022, 04:24 PM)shaylavi Wrote: Im shooting a rigidbody that a rope is attached to and making it longer cursor.ChangeLength() until it reaches a wall.
When it does I "lock" the length and then the player (which is attached to the other side of the rope) gets a massive velocity change towards the shot rigidbody.
Anyway to cancel out this velocity?

Hi!

Well, this depends on a lot of things:
- Where's the cursor placed along the rope?
- Are you setting the length instantly (in a single frame) or over multiple frames?
- What's the mass of the rope compared to the mass of the player?

If your rope is heavy compared to the player and the length is changes in a single frame, then the player will be catapulted towards the shot rigidbody, this is the expected behavior. Imagine launching a projectile to which you're attached via a heavy chain, the combined inertia of the chain + the projectile would pull from you.

You can check out the included RopeGrapplingHook sample scene for an example of how to implement a grappling hook.

kind regards,
Reply
#3
(29-08-2022, 05:43 PM)josemendez Wrote: Hi!

Well, this depends on a lot of things:
- Where's the cursor placed along the rope?
- Are you setting the length instantly (in a single frame) or over multiple frames?
- What's the mass of the rope compared to the mass of the player?

If your rope is heavy compared to the player and the length is changes in a single frame, then the player will be catapulted towards the shot rigidbody, this is the expected behavior. Imagine launching a projectile to which you're attached via a heavy chain, the combined inertia of the chain + the projectile would pull from you.

You can check out the included RopeGrapplingHook sample scene for an example of how to implement a grappling hook.

kind regards,
Thank you for your response josemendez!

1. Where should the cursor be located along the rope?
2. I'm setting the length of the rope in the update function until the rigidbody at the end of the rope collides with something.
3. They are the same mass. I tried increasing the mass of the player but the rope becomes too stretchy (even after all your suggestions for increasing rope stiffness).

Is there a way to cancel the rope velocity at the frame which the rigidbody collides?
Reply
#4
(29-08-2022, 06:17 PM)shaylavi Wrote: Thank you for your response josemendez!

1. Where should the cursor be located along the rope?

Depends on what you want to do, for grappling hooks / swings it is usually places at the start of the rope, near the character (mu parameter set to 0).

(29-08-2022, 06:17 PM)shaylavi Wrote: 2. I'm setting the length of the rope in the update function until the rigidbody at the end of the rope collides with something.

If you're setting the length in Update(), you're changing the length and simulating the rope out of sync. It's better to do it in FixedUpdate().

(29-08-2022, 06:17 PM)shaylavi Wrote: 3. They are the same mass. I tried increasing the mass of the player but the rope becomes too stretchy (even after all your suggestions for increasing rope stiffness).
Is there a way to cancel the rope velocity at the frame which the rigidbody collides?

You can set the velocity of all particles to zero using the particles API:
http://obi.virtualmethodstudio.com/manua...icles.html

However I'm still not 100% sure where that impulse originates from: If you're setting the length of the rope in Update() to be the distance between the character and the rigidbody, then by the time the rigidbody hits a wall the rope should not be stretched and pull from the character.

The character can only move due to the inertia of the rope, in the included GrapplingHook scene this is avoided by fixing particles in place while the rope is being shot towards the wall: particles have their inverse masses set to zero (this excludes them from the simulation) and their position is manually updated. Have you tried this sample scene? sounds very similar to your use case, and already solves the issue you're describing.

kind regards,
Reply