(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...?