Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Particle Attachment on expanding rope
#1
Pregunta 
Hi,

I've a rope around 1 unit long, it's attached to a rod by the first and last particle with 2 static particle attachments.
On this rope there is cursor, depending on an object position (a VR controller) the cursor will either have the cursor at 0 or 1 (source always at .5) . Imagine you are pulling a rope either from the start or end.
So this rope can get bigger if you pull, everything works fine here.
Now when pulling I want to attach the closest particle from the controller to it. I'm getting the closest particle (avoiding the first and last) and create the attachment using this script:

Code:
                particleAttachment = rope.gameObject.AddComponent<ObiParticleAttachment>();
                particleAttachment.enabled = false;
                particleAttachment.target = m_Controller;

                var group = ScriptableObject.CreateInstance<ObiParticleGroup>();
                group.particleIndices.Add(attachedParticleIndex);
                group.name = "Test";


                particleAttachment.particleGroup = group;
                particleAttachment.attachmentType = ObiParticleAttachment.AttachmentType.Static;
                particleAttachment.enabled = true;

And the behavior is weird, sometimes it works, sometimes points get stuck in the air like if they were attach to a world position. I feel like it's because I'm expanding the rope while dragging and sometimes the source particle can become the one attached?

Do you see any edge cases with this system?

Thanks a lot.
Reply
#2
Hi!

I assume you're attaching the closest particle first, then when the user pulls the rope you detect the amount of stretch in the rope and increase its length based on this? As long as the attachment is behind the cursor and you're only increasing its length (that is, the particle is not in front of the cursors and it consumes particles until the attached particle is gone from the rope) then it should work fine.

When you say "gets stuck as if attached to a world position" do you mean stuck in the air and not following the attachment at all, or following the attachment but there's an offset/gap between the particle and the point you'd expect it to be attached to?

kind regards,
Reply
#3
(26-06-2024, 09:39 AM)josemendez Wrote: Hi!

I assume you're attaching the closest particle first, then when the user pulls the rope you detect the amount of stretch in the rope and increase its length based on this? As long as the attachment is behind the cursor and you're only increasing its length (that is, the particle is not in front of the cursors and it consumes particles until the attached particle is gone from the rope) then it should work fine.

Exactly I'm attaching the particle first, then I get the distance from the initial position to a new one each frame an increase the length of the rope, it works fine sometimes, so I get it has to do with the cursor position, I'll try to fix that.


Quote:When you say "gets stuck as if attached to a world position" do you mean stuck in the air and not following the attachment at all, or following the attachment but there's an offset/gap between the particle and the point you'd expect it to be attached to?


Yes stuck in the air and not following the attachment after some time / distance. It could be the same issue as above.

Should I move the cursor dynamically when extending the rope?
Reply
#4
From my quick tests, changing the source position fixed it.
Thank you!
Reply