Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Rope Attachment on dynamic rope length and Stitching questions
#1
Hi,

I have a rope with multiple controls points. I want to dynamically attach something to the last control point at runtime. It works perfectly fine when the rope length is not changed using the Cursor, but if I change the length to say .2f, and then change it again to anything and try to attach the last control point it will attach to a "random" point on the rope. So my guess is that the controls points are moved when changing the length. Any way to solve that?

Fixed it: I  wasn't using the particle group correctly it seems.


My second question is that I have a obi bone setup for a model, and at the end of the model I've stitch the rope, when there is constraint there is a gap between the model and the rope, and it can get huge depending on the constraint. How can i fix that even if it's just visual?

Also with the same object, the bones are rotating when moving the object, how can i fix that? 

Thanks a lot!
Reply
#2
(14-04-2023, 04:43 PM)Balou Wrote: My second question is that I have a obi bone setup for a model, and at the end of the model I've stitch the rope, when there is constraint there is a gap between the model and the rope, and it can get huge depending on the constraint. How can i fix that even if it's just visual?

Yes, depending on how large the force applied to a constraint is, your solver "budget" might not be enough for it to keep particles from separating. If you don't want to spend more substeps in the simulation, a simple solution is to set the renderablePosition of both particles to the same value during the solver's OnInterpolate event. This is just visual, won't affect the simulation.

(14-04-2023, 04:43 PM)Balou Wrote: Also with the same object, the bones are rotating when moving the object, how can i fix that? 

What exactly do you mean? Bones are usually children of the root object, so they are expected to rotate together with the object.

kind regards,
Reply
#3
(17-04-2023, 07:34 AM)josemendez Wrote: Yes, depending on how large the force applied to a constraint is, your solver "budget" might not be enough for it to keep particles from separating. If you don't want to spend more substeps in the simulation, a simple solution is to set the renderablePosition of both particles to the same value during the solver's OnInterpolate event. This is just visual, won't affect the simulation.

I still have a gap between the last ObiBone (a rod) particle and the first rope particle.

Code:
private void Solver_OnInterpolate(ObiSolver solver)
    {
        int firstRopeParticle = rope.elements[0].particle1;
        int lastRodParticle = rod.solverIndices[rod.solverIndices.Count() - 1];
        Vector3 pos = solver.renderablePositions[lastRodParticle];
        solver.renderablePositions[firstRopeParticle] = pos;
    }


(17-04-2023, 07:34 AM)josemendez Wrote: What exactly do you mean? Bones are usually children of the root object, so they are expected to rotate together with the object.

I'm not sure, something is wrong with the bone rotation, so it looks like there is torsions on the 3d model, the gizmos look like that on the model I've been using:

   
   

But if I import the exact same model in the same scene, and place a Obi Bone component on it, it looks fine:

   


I've checked my bone rotation, and apart from the first one they are all 0,0,0. And scale is right in the editor, all 1,1,1

Thanks,
Reply
#4
(17-04-2023, 02:48 PM)Balou Wrote: I'm not sure, something is wrong with the bone rotation, so it looks like there is torsions on the 3d model, the gizmos look like that on the model I've been using:
[...]
But if I import the exact same model in the same scene, and place a Obi Bone component on it, it looks fine:

I don't think I'm understanding the issue: you state that if you import the model in the scene and add a ObiBone component to it, it looks fine. However in some other situation there seems to be something wrong with bone torsion, but it's not clear to me what this other situation is. Is this in a different scene, or with a different object?
Reply
#5
Same scene, same model, the one not working has been in the scene for quite a while. For now I'll replace it but I hope it doesn't happen again because it's annoying! 


What about this? Am I doing the right thing:

Quote:I still have a gap between the last ObiBone (a rod) particle and the first rope particle.

Code:

Code:
private void Solver_OnInterpolate(ObiSolver solver)
    {
        int firstRopeParticle = rope.elements[0].particle1;
        int lastRodParticle = rod.solverIndices[rod.solverIndices.Count() - 1];
        Vector3 pos = solver.renderablePositions[lastRodParticle];
        solver.renderablePositions[firstRopeParticle] = pos;
    }

Thanks a lot.
Reply
#6
(18-04-2023, 12:45 PM)Balou Wrote: Same scene, same model, the one not working has been in the scene for quite a while. For now I'll replace it but I hope it doesn't happen again because it's annoying! 


What about this? Am I doing the right thing:


Thanks a lot.

Hi!

That looks (and works) just fine for me. Tried sewing a rope to a rod, added your code to a component and these are the results:

Component disabled (set stitch constraint relaxation to its minimum to exaggerate the gap):
[Image: Zt00VnD.png]

Component enabled:
[Image: 9Go8gs8.png]

This is the code I used:

Code:
using UnityEngine;
using Obi;

public class VisualGapBridge : MonoBehaviour
{
    public ObiRope rope;
    public ObiRod rod;

    void OnEnable()
    {
        GetComponent<ObiSolver>().OnInterpolate += VisualGapBridge_OnInterpolate;
    }

    void OnDisable()
    {
        GetComponent<ObiSolver>().OnInterpolate -= VisualGapBridge_OnInterpolate;
    }

    private void VisualGapBridge_OnInterpolate(ObiSolver solver)
    {
        int firstRopeParticle = rope.elements[rope.elements.Count-1].particle2;
        int lastRodParticle = rod.solverIndices[rod.solverIndices.Length - 1];
        Vector3 pos = solver.renderablePositions[lastRodParticle];
        solver.renderablePositions[firstRopeParticle] = pos;
    }
}

Note that depending on which ends you stitch together, you might want to use the last/first particle on either the rope or the rod. In my case I stitched the end of the rope to the end of the rod, so had to change:

Code:
rope.elements[0].particle1; // first particle

to

Code:
rope.elements[rope.elements.Count-1].particle2; // last particle
Reply
#7
Edit; Fixed, by using the OnInterpolate from the rod (obiBone) instead of the solver's onInterpolate.

All right so this confirms the problem is elsewhere.
   

You can see on this screenshot, the rope (bright yellow) and the rod in black, the rod is again, using Obi Bone. 
The yellow sphere is the last rod particle: int lastRodParticle = rod.solverIndices[rod.solverIndices.Count() - 1];
So the issue is not the script but the last rod particle is not set with the model probably due to heavy constraint (something "heavy" is attached at the end of the rope).

So instead of setting the end of the rope to the end of the obi bone, I tried setting it to the position of the last bone, because it should be accurate visually, but now the issue is something is fighting with it, so the end of the rope is "flickering" between two positions.

   

   

One looks like the rest position of the obi bone? And the other is the last bone (which i want).
Any idea what is happening, feel like it's close!

To recap the components used:
- Rope
- ObiBone on a 3d model
- Stitching between the two
Reply
#8
(19-04-2023, 03:06 PM)Balou Wrote: All right so this confirms the problem is elsewhere.


You can see on this screenshot, the rope (bright yellow) and the rod in black, the rod is again, using Obi Bone. 
The yellow sphere is the last rod particle: int lastRodParticle = rod.solverIndices[rod.solverIndices.Count() - 1];
So the issue is not the script but the last rod particle is not set with the model probably due to heavy constraint (something "heavy" is attached at the end of the rope).

Regardless of how heavy the object attached at the end of the rope is, you're explicitly forcing the rendered position of both ends to be the same: there should be no separation.


(19-04-2023, 03:06 PM)Balou Wrote: So instead of setting the end of the rope to the end of the obi bone, I tried setting it to the position of the last bone, because it should be accurate visually, but now the issue is something is fighting with it, so the end of the rope is "flickering" between two positions.

The position of the last bone is the same as the position of the last particle, every frame all bones are moved to the position of the particle driving them. There should be no difference between setting it to the bone or the bone particle, since they're the same (keep in mind that particles are expressed in solver space though, and bone positions are expressed in either world space or their parent bone's space!)

At this point I can't really think of any reason for this. Maybe the rod and the rope are simply colliding with each other? Are particle collisions enabled in your ObiSolver and if so, what collision filter settings are you using for your bone hierarchy and your rope?

kind regards,
Reply
#9
I edited my post and didn't see your answer, it is fixed now. There was no collision between the two.

I fixed by using the end bone position and using the onInterpolate of the actor instead of the solver. 

Thank you for the help!
Reply
#10
I know it's an old thread but the issue is back and the images are still relevant. 
I updated the plugin recently and I've got the exact same issue about the renderablePositions doing these weird things. I can still see the rope switching between 2 positions if I'm using rope.solver.OnInterpolate, and doing nothing if I'm using rope.OnInterpolate.
It feels like something is overriding my renderablePositions at some point.
Any help really appreciated.
Thanks
Reply