Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How to guarantee a rope will not go through a collider?
#1
Hi all,

Sorry if the question is not so precise or has already been answered earlier but here we go.

I'm trying to reproduce some of the rope mechanics as seen in The Last Of Us Part 2 because it's so fun (as reference: https://www.youtube.com/watch?v=VTRzaE3T5to).

I've got a lot of rocks, not so much buildings. Everything is mesh collider.

My avatar hold the rope and I make it grow (with a cursor) to a maximum points.

But when the rope need to be in tension (stretch), I often got the rope penetrating the collider.

I realize that's a tricky situation since I think I'm stressing the system by stretching the particles.


So I'm trying to tweak the lenght of the rope, but I still want it to feel stretched especially when the avatar is going to the opposite side of the rope!
I also tried to increase the solver Collision iterations.
My rope also use "surface-based collisions" since I think it will help detect collision between particles.
I considered using signed distance field, but there is too many different rock meshes and I think it will be too memory costly to store signed distance field.

I still get cases where the rope go inside a collision.

So my question is: how to prevent this from happening?
1) do I miss something obvious on the settings?
2) is it something that Obi solver can let us now by telling us "I couldn't solve this and a particle possibly went inside a collision"
3) can I help the system in some way? (at some point I was considering making some raycasts and spawn simpler collision shapes like spheres to "help" the solving but I don't know if it will work, it seems way to naïve). At some point in the Last Of Us video above (at 0:57 to be precise) we see that the rope is in tension and enter the wall... but the frame after there is a correction going on... and it's impressive!

Thanks for any help or advices!

And thanks for the plugin, it's fun to play around with it, but hard to master so far!
Reply
#2
(22-05-2023, 04:24 PM)Guillaume Wrote: Hi all,

Sorry if the question is not so precise or has already been answered earlier but here we go.

I'm trying to reproduce some of the rope mechanics as seen in The Last Of Us Part 2 because it's so fun (as reference: https://www.youtube.com/watch?v=VTRzaE3T5to).

I've got a lot of rocks, not so much buildings. Everything is mesh collider.

Hi!

Mesh colliders are "hollow", only their surface generates collisions. As soon as an object is entirely inside a MeshCollider, it can't be projected back outside because there's no way to tell if a point is inside or outside a MeshCollider (there might even be no inside/outside at all!). You can easily test this using regular objects in Unity.

Distance fields are designed for this use case. It's not only possible to tell if a point is inside or outside of them, but they're also considerably faster than MeshColliders.

(22-05-2023, 04:24 PM)Guillaume Wrote: 2) is it something that Obi solver can let us now by telling us "I couldn't solve this and a particle possibly went inside a collision"

If the solver is able to detect a collision, it can solve it. Collisions are solved last in the constraint hierarchy so they're always respected. The problem is that once a rope particle tunnels trough a triangle in a MeshCollider (due to a missed collision, or user input forcing the rope trough the collider's surface), there's no way to recover from it because it's impossible to tell if a point is inside an arbitrary triangle soup.

Also, keep in mind that The Last of Us' rope does not appear to be purely particle/body based. Judging from the videos (couldn't find any technical info about their approach anywhere) they're using a hybrid lagrangian/eulerian approach, switching between them based on rope tension: when the rope is under enough tension (for instance when a character is hanging from a rope) they seem to switch to an eulerian representation using the contact points in the rope as nodes trough which the rope slides.

(22-05-2023, 04:24 PM)Guillaume Wrote: And thanks for the plugin, it's fun to play around with it, but hard to master so far!

You're welcome! Sonrisa Regular rigidbodies are already challenging, but deformable body physics -such as ropes- are probably the second hardest thing to get right in simulation, only surpassed by fluids. Keep at it!
Reply
#3
Hi Jose, thanks for your fast and detailed reply!

So I guess Signed Distance Field will be the way to go for me to tackle that penetration issue. 

I was thinking that maybe I was missing the equivalent of Continous Collision Detection with my rope.
Actually I was thinking that the "surface-based collisions" was maybe dealing with avoiding particles to go through a triangle between steps of the simulation.

I think I understand the tricky part of understanding "where we are in that vertices soup" Sonrisa 


I don't know how they've handled the ropes in TLOU2 but it's super impressive. Hopefuly I'm not targeting the exact same behaviour but I which they will give some talks some days!

In the meantime I'm going to see if Signed Distance Field are not producing too much memory, that's my only fear.

Thanks!
Reply
#4
If I may hijack this thread, I‘m trying something similar where I‘m reducing the ropes length through Cursor, while the end is attached to a fixed point. I need to make sure the rope doesn‘t go through colliders along the way and basically stops the Cursor. Here‘s a sophisticated drawing, the first one shows the intended behaviour when the rope cursor is at the point where the rope shouldn’t shorten any further.

Any tips?
I‘m currently doing this by checking the rest length and not allowing further shortening that way. But that way I have to trial & error the min length and it‘s not very scalable.


Attached Files Thumbnail(s)
       
Reply
#5
(08-02-2024, 03:14 PM)lela_tabathy Wrote: If I may hijack this thread, I‘m trying something similar where I‘m reducing the ropes length through Cursor, while the end is attached to a fixed point. I need to make sure the rope doesn‘t go through colliders along the way and basically stops the Cursor. Here‘s a sophisticated drawing, the first one shows the intended behaviour when the rope cursor is at the point where the rope shouldn’t shorten any further.

Any tips?
I‘m currently doing this by checking the rest length and not allowing further shortening that way. But that way I have to trial & error the min length and it‘s not very scalable.

You could compare the rope's rest length to its current length, to see if the rope is overly stretched. If it is, stop the cursor (or even reel out a bit of rope length to reduce strain).

Code:
float strain = rope.CalculateLength() / rope.restLength; // this will be >1 when stretched, <1 when compressed, 1 when under no forces.

let me know if you need further help,

cheers
Reply