Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Obi Rope attachment
#1
Bug 
Hello,

I'm working on a rope system to move objects, and I have something that is working. The problem is that, when I change the lenght of a rope (usually when it becomes smaller), the Particle Attachment seems to not be working... All my code to AddComponent works usually, but when the rope has been shorten, the ParticleAttachment is being added but the rope doesn't move, and the object attached becomes crazy...
Does anyone has a solution ? :/

Thanks in advance for your answers, and have a nice day !

(under, two screenshots to help to understand)

Edit : added a video to help understand (not eng native speaker sooo not easy for me..)
https://youtu.be/b2h1QB8CQEg


Attached Files Thumbnail(s)
       
Reply
#2
https://youtu.be/b2h1QB8CQEg

Just recorded the "bug" that I've encoutered, I'm not a native english speaker so it's not easy to descrbe my problem :')
Reply
#3
(29-06-2023, 01:36 PM)parzi Wrote: https://youtu.be/b2h1QB8CQEg

Just recorded the "bug" that I've encoutered, I'm not a native english speaker so it's not easy to descrbe my problem :')

Hi,

In the video it looks like the attachments are being added dynamically when the cube is close to or in contact with the rope. May you share the code you're using to do this?

kind regards,
Reply
#4
(30-06-2023, 07:05 AM)josemendez Wrote: Hi,

In the video it looks like the attachments are being added dynamically when the cube is close to or in contact with the rope. May you share the code you're using to do this?

kind regards,

Hello ! I've make a rope prefab, and in this prefab there's a Cube without mesh, triggered, and the rope has a Particle Attachment to this Cube on the particle End.

The script on the Cube is :

private void OnTriggerEnter(Collider other)
{
if (other.gameObject.layer == LayerMask.NameToLayer("Grabbable") && !HasTouch)
{
HasTouch = true;
ObiParticleAttachment attach = rope.AddComponent<ObiParticleAttachment>();
attach.target = other.transform;
attach.particleGroup = rope.GetComponent<ObiRope>().blueprint.groups[rope.GetComponent<ObiRope>().blueprint.groups.Count - 1];
attach.attachmentType = ObiParticleAttachment.AttachmentType.Dynamic;
GetComponentInParent<GrabbableLmts>().grabbableObject = other.gameObject;
}
}


Now that I'm looking at it, isn't it the "rope.GetComponent<ObiRope>().blueprint.groups[rope.GetComponent<ObiRope>().blueprint.groups.Count - 1];" that is a wrong way to do when I'm changing the lenght of the rope ?

Thank you for your time !

Okay I've tested and now I'm sure that it's the problem... It's like if I was attaching it to an inactive particle right ? Then, is it possible to detect if the particle is active ? Or maybe could I add a particle at the end of the rope, with its lenght parameter, at runtime...?

Okay I've tested and now I'm sure that it's the problem... It's like if I was attaching it to an inactive particle right ? Then, is it possible to detect if the particle is active ? Or maybe could I add a particle at the end of the rope, with its lenght parameter, at runtime...?
Reply
#5
Tryied to find a way to access the last one active with the ObiStructuralElement class (because it seems that you're doing that in the ChangeLenght function in ObiRopeCursor but can't find anything working Triste
Reply
#6
(30-06-2023, 07:05 AM)josemendez Wrote: Hi,

In the video it looks like the attachments are being added dynamically when the cube is close to or in contact with the rope. May you share the code you're using to do this?

kind regards,

I'm experiencing the same problem (at least I think so), for what it's worth.

When I create a dynamic attachment at runtime on the last particle of a short rope, the same behavior is observed.

Here's my code that moves the particle using the actor's elements and enables the attachment:

lineEndAttachment.enabled = false;
var fish = _fish[_currFishIndex];

var localPosition = fishingLine.solver.transform.InverseTransformPoint(fish.transform.position);
int lastParticleIndex = fishingLine.elements[^1].particle2;

fishingLine.solver.positions[lastParticleIndex] = localPosition;


lineEndAttachment.target = fish.transform;
lineEndAttachment.enabled = true;


Edit: it actually happens any time after the cursor has shortened the rope. It seems my method for getting the last particle stops working after that.
Reply
#7
Found a workaround: if the rope starts at a short length (< .25m) then the attachments work correctly, regardless of the length set by the cursor at runtime.
Reply