Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Ropes // Couple of questions
#1
Hi!

We are more and more getting comfortable using ObiRope in our projects and we are learning something new every time. 
This also means that we get stuck again on certain points and I would like to ask for some help Sonrisa

To set the scene:
- We have a cable that comes from a reel on a vessel
- The cable extends and goes in the water
- Once the cable is extended and at the ocean floor we need to attach the cable to an object on the floor
- This attachement point is not the beginning/end and is not a pre-determined location

I figured out with the documentation how to extend the cable to make it seem like its extending from a reel. 
This looks very nice and works perfectly! 

The next part that I'm stuck at is attaching the the cable to an object.
Usually I would:
- Make a rope blueprint
- Add controlpoint
- Add ObiAttachement component
- Attach an object to the Attachment component and assign the correct controlpoint
- Animate the objects transform to then also animate the cable behaviour at that point. 

Though, in this case the situation is different as there is no rope blueprint with fixed controlpoints.
I can see in the documentation that you can add attachments during runtime but I don't quite understand how to do this. 

I would think we need to know the following:
- Which element has the particles that we want to control
- Add a ObiAttachment
- Assign an object to the ObiAttachment

I'm no pro in scripting unfortunately and this is where I'm getting stuck.
I wanted to visualize the particles to get an idea of how the particles are positioned during runtime but the ObiParticleRenderer component doesn't seem to work and I can't seem to get it to work in any of the demo scenes either. Am I missing something obvious here? I'm using Unity2022 HDRP, and the Render checkbox is ticked in the component. 

I have two screenshots attached to this post.
Hopefully my question makes sense Gran sonrisa

Thanks in advance!

Kind regards


Attached Files Thumbnail(s)
       
Reply
#2
(04-05-2023, 10:05 AM)5G_Zendmast Wrote: The next part that I'm stuck at is attaching the the cable to an object.
Usually I would:
- Make a rope blueprint
- Add controlpoint
- Add ObiAttachement component
- Attach an object to the Attachment component and assign the correct controlpoint
- Animate the objects transform to then also animate the cable behaviour at that point. 

Though, in this case the situation is different as there is no rope blueprint with fixed controlpoints.

Hi!

You can create particle groups at runtime, in addition to the ones automatically created when generating the blueprint (one per control point). The manual shows some sample code to do this:

Code:
var group = ScriptableObject.CreateInstance<ObiParticleGroup>();
group.particleIndices.Add(particleIndex); // index of the particle in the actor
attachment.particleGroup = group;

let me know if you need further help,

kind regards
Reply
#3
(11-05-2023, 10:22 AM)josemendez Wrote: Hi!

You can create particle groups at runtime, in addition to the ones automatically created when generating the blueprint (one per control point). The manual shows some sample code to do this:

Code:
var group = ScriptableObject.CreateInstance<ObiParticleGroup>();
group.particleIndices.Add(particleIndex); // index of the particle in the actor
attachment.particleGroup = group;

let me know if you need further help,

kind regards


Hi Jose, 

Thanks for your reply.
With your information I got it to work with the following code.
Do you maybe see anything that might cause a problem or that i'm using in a wrong way?

Code:
void AddControllPoint(int index)
    {
        var group = ScriptableObject.CreateInstance<ObiParticleGroup>(); //Create a particle group
        group.particleIndices.Add(index); // index of the particle in the actor

        int pickedParticle = rope.elements[index].particle2; //store particle index
        var particlePos = rope.solver.positions[pickedParticle]; //store the position of the particle
        attObject.transform.localPosition = particlePos; //Move the attachment object to the stored particles location

        var attachment = actor.AddComponent<ObiParticleAttachment>(); //Create an Attachment component
        attachment.target = attObject.transform; //add an object as target in the Attachment component
        attachment.particleGroup = group; //Assign the particle group to the target

        addControlPoint = false;
        Debug.Log("Control Point Created");
    }

Besides this I'm still wondering if you could help me with how to visualize the particles.
The only way I get to see the particles is when using ObiInstancedParticleRenderer and disabeling the mesh renderer of the rope.
Is that the only way to visualize the particles or am I missing something in the ObiParticleRenderer component?

Thanks again for your help and I'm a step closer once again Sonrisa

Kind regards, 

Patrick


EDIT:
I think I cheered a bit to early haha.
The script seems to work perfectly for a rope that keeps its original blueprint (first attachment).
But after I extended the rope during runtime and I want to add a attachment the object goes to the correct transform (at least it acts the way I expect it to act) but the particle it's attached to seems to be off (or the other way around) 

In the 2nd attachment you can see the cube is placed somewhere along the rope but when I move the cube around it's attached to the wrong (?) particle. 
Yesterday I only tested it with the original blueprint and not after the rope is extended during runtime. 

Does this maybe have to do with the allocation of particles during runtime? (http://obi.virtualmethodstudio.com/manua...ropes.html)


Attached Files Thumbnail(s)
       
Reply