Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Relax the rope when required
#1
Hi,
I experience weird rope behaviour in some cases when attaching parent Rigidbody object. Here is the video 
This doesn't happen in 100% of cases. Pencil - is a parent rigidbody and the paperclip is rigidbody object attached to the same rope.
Is there any way to avoid it? MAybe "force relax" the rope somehow?
Reply
#2
(12-02-2024, 03:43 AM)Romahaaa Wrote: Hi,
I experience weird rope behaviour in some cases when attaching parent Rigidbody object. Here is the video 
This doesn't happen in 100% of cases. Pencil - is a parent rigidbody and the paperclip is rigidbody object attached to the same rope.
Is there any way to avoid it? MAybe "force relax" the rope somehow?

Hi,

Make sure that the rope isn't attached inside of/intersecting the paperclip or the pencil, as this will result in sudden jerks as the rope tries to escape the collider - but can't, since it is attached to it. See "attachments inside colliders":

http://obi.virtualmethodstudio.com/manua...ments.html
Reply
#3
Ok, tried to adjust colliders and rope position. I could make it easy for paperclip, but can't set it well for pencil because there is a visible gap between pencil and rope.

I checked to doc link you provided where described the approach of collision masking. I didn't get how I can add masking to the rope itself. Paper clip and pencil has same category, and they collides with everything... Didn't understand how to setup masking properly without assigning the rope to any of the group
That's how I setup the ObiRope.
And here is the paper clip and pencil setup.
Reply
#4
(14-02-2024, 04:48 AM)Romahaaa Wrote: Ok, tried to adjust colliders and rope position. I could make it easy for paperclip, but can't set it well for pencil because there is a visible gap between pencil and rope.

No need to adjust collider positions, it is usually simpler/better to use collision filters to disable collisions between the particles at the end of the rope and these specific colliders.

(14-02-2024, 04:48 AM)Romahaaa Wrote: Didn't understand how to setup masking properly without assigning the rope to any of the group

You can specify category and mask for each control point in the path editor:

http://obi.virtualmethodstudio.com/manua...sions.html
Quote:All ObiActors allow you to set categories and masks for individual particles. Depending on the actor, this is done in slightly different ways:[...]
ObiRope / ObiRod: category and mask are specified on a per-control point basis using the path editor.

For info on the path editor, see:
http://obi.virtualmethodstudio.com/manua...setup.html

Since your colliders are on group 2, set your rope's control point(s) to collide with everything except group 2. Check the Crane sample scene, it uses this approach to disable collisions between the crane's load cube and the tip of the rope.

kind regards,
Reply
#5
(14-02-2024, 06:58 AM)josemendez Wrote: You can specify category and mask for each control point in the path editor:
Right, I just forgot about it, the scene was set long time ago.

Anyway, I did everything as you described, checked docs again, but the jittering issue still exist.
I did that way:

Scene environment colliders - group 1 and don't have any collision mask
Pencil and Paper Clip - group 2 and have collision mask to group 15 (rope). I also tried to set to everything, but it didn't help.
Rope - group 15 and have collision mask to group 2 (pencil and paper clip)
   

but.. even if this will work as expected without jittering, I see another problem here - when rope falls onto pencil or paperclip, it will go through their physics colliders..

And the conclusion to all my tests - even combining 2 approaches - avoid rope point intersection with pencil/paperclip colliders and settings up the collision group and masks I still have this issue. Seems the problem is somewhere else
   


Attached Files Thumbnail(s)
   
Reply
#6
Hi!

Your collision filters are correctly set up.

(15-02-2024, 04:59 AM)Romahaaa Wrote: but.. even if this will work as expected without jittering, I see another problem here - when rope falls onto pencil or paperclip, it will go through their physics colliders..

Rope particles will inherit the properties of their closest control point via interpolation:
http://obi.virtualmethodstudio.com/manua...setup.html

Quote:In the path editor you can add/remove control points, move/rotate/scale existing control points, and set per-control point properties that will be interpolated to the rope particles.

If your rope only has two control points (one at each end) and you set their collision filters to disable collisions, then all particles in the rope will stop colliding since they can only be close to either control point.

You only need a few particles close to the ends of the rope to skip collisions, so you can add a couple extra control points to get particles in the middle of the rope to collide as usual. Excuse my poor diagram:

(O): control point set to not collide.
(X): control point set to collide.
-: particle that doesn't collide
+: particle that collides


PENCIL  (O)---+++(X)++++++++++++++++(X)+++---(O)  PAPERCLIP


Once the rope is set up this way, both the pencil and the paperclip can safely intersect the ends of the rope, no need to leave a gap between them. See the "Crane" or "FreightLift" sample scenes (and most other scenes involving attachments) as they use collision filters this way.

(15-02-2024, 04:59 AM)Romahaaa Wrote: And the conclusion to all my tests - even combining 2 approaches - avoid rope point intersection with pencil/paperclip colliders and settings up the collision group and masks I still have this issue. Seems the problem is somewhere else

Other than collisions there isn't any other obvious culprit. Pencil movement doesn't seem to be the culprit, since in the video the rope jumps upwards right after the pencil stops moving.

A similar issue could be caused a very large sudden drop in performance: since physics integrate velocities over time using the time passed since the last frame (delta time), if a frame takes very long to render then the position of the paperclip will be very different from last frame (position += velocity * deltaTime) and the rope will need to apply a very large force the next frame to bring it back into place, causing it to jump. While unlikely to happen in a simple game, you can check the profiler to see if there's any spikes in performance that coincide with the rope jumping. If that's the case, finding and fixing the cause of the spikes would get rid of the issue.

Anyway, would it be possible for you to build a small scene/project that reproduces this issue and send it to support(at)virtualmethodstudio.com, so that i can take a closer look and be able to help more effectively?

kind regards,
Reply
#7
(15-02-2024, 07:18 AM)josemendez Wrote: Anyway, would it be possible for you to build a small scene/project that reproduces this issue and send it to support(at)virtualmethodstudio.com, so that i can take a closer look and be able to help more effectively?

Not that easy... That's a complex and big project and need to split movement logic from there as well. In short - the object has different Rigidbody parameters in idle/drag/attach states. Seems the issue appears exactly when state changes from drag(snap) to attach. 
I think it's just easier to replicate that base logic with parameters change in different conditions. This will take pretty a lot of time.

Maybe you may give me some hints where to search? For example, does rope react on isKinematic toggle, or Sleep(), physics collider toggle to isTrigger or something else?
Reply
#8
Posting the solution here based on our email chat with the developer. Just in case if someone will have similar issue

Me
Quote:Trying to reproduce the same issue, it seems I found the parameter which causes the rope jittering on attach - it's Physics > Sleep Threshold. It was set to 0.001 while Unity default value is 0.005. 
Changing that in the Unity project I sent, you may notice the issue I described. 

I am not 100% sure I can change it back to default 0.005 (most likely there was a reason for that). Would be good to figure out and close that question - is it expected behaviour or not. 

Jose (or other developer) answer
Quote:Sleep threshold determines the kinetic energy level below which rigidbodies are considered static. Bodies that stay below this threshold for a while are assumed to not be moving anymore so they're put to "sleep" -skipped by the simulation-  to save resources, until they wake up due to external forces being applied to them.

If your sleep threshold is too low it might cause objects to never go to sleep, or constantly alternate between sleep/awake. If it's too high, bodies will fall asleep and stop moving even when they should not. Under normal circumstances, the default value is good and should not cause problems. 
 
An excessively low sleep threshold might be causing the rigidbody that's hanging from the rope to briefly enter the asleep state. As you move the top of the rope, it gets slightly stretched since the rigidbody is asleep and unable to move. Once it wakes up due to the rope attempting to modify its velocity and becomes able to move again, you get the slingshot-like behavior in your original post.
Reply