Rope pulling problem - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html) +--- Thread: Rope pulling problem (/thread-3569.html) |
Rope pulling problem - shaylavi - 29-08-2022 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 RE: Rope pulling problem - josemendez - 29-08-2022 (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. 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, RE: Rope pulling problem - shaylavi - 29-08-2022 (29-08-2022, 05:43 PM)josemendez Wrote: Hi!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? RE: Rope pulling problem - josemendez - 30-08-2022 (29-08-2022, 06:17 PM)shaylavi Wrote: Thank you for your response josemendez! 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). You can set the velocity of all particles to zero using the particles API: http://obi.virtualmethodstudio.com/manual/6.3/scriptingparticles.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, |