Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Some questions & requests
#11
(08-08-2022, 02:24 PM)josemendez Wrote: If you wanted to get rid of this, you would need to teleport all particles in the rope to a new position and not just the ends (placing them in a straight line from Origin transform to End transform is a good idea). Also set all particle velocities to zero to remove any unwanted velocity from the previous use of the rope.

Hi again!

Ok, I did it and it almost worked 100%!
The attachment, position and motion are now fine, but, for some reason, the end point is sometimes being dettached. Here you can see this:
https://streamable.com/d1ticx

Here's how the code is:

Code:
public void Connect(Transform origin, Transform end)
{
    cursor.ChangeLength((end.position - origin.position).magnitude);
   
    for (var i = 0; i < rope.elements.Count; i++)
    {
        ObiStructuralElement element = rope.elements[i];
        float t = (float)i / (float)rope.elements.Count;
        Vector3 position = Vector3.Lerp(origin.position, end.position, t);
        int particleIndex1 = element.particle1;
        int particleIndex2 = element.particle2;
        rope.solver.positions[particleIndex1] = position;
        rope.solver.positions[particleIndex2] = position;
       
        rope.solver.velocities[particleIndex1] = Vector4.zero;
        rope.solver.velocities[particleIndex2] = Vector4.zero;
    }

    attachment1.enabled = true;
    attachment2.enabled = true;
    attachment1.target = origin;
    attachment2.target = end;
}

public void Disconnect()
{
    attachment1.target = null;
    attachment2.target = null;
    attachment1.enabled = false;
    attachment2.enabled = false;
}

Once again, sorry for bothering you so much but thank you for the amazing support!  Corazón
Reply


Messages In This Thread
Some questions & requests - by landosilva - 04-08-2022, 10:58 PM
RE: Some questions & requests - by josemendez - 05-08-2022, 07:57 AM
RE: Some questions & requests - by landosilva - 05-08-2022, 03:34 PM
RE: Some questions & requests - by josemendez - 05-08-2022, 04:17 PM
RE: Some questions & requests - by landosilva - 06-08-2022, 02:59 PM
RE: Some questions & requests - by josemendez - 08-08-2022, 07:44 AM
RE: Some questions & requests - by landosilva - 08-08-2022, 09:46 AM
RE: Some questions & requests - by josemendez - 08-08-2022, 10:54 AM
RE: Some questions & requests - by landosilva - 08-08-2022, 02:09 PM
RE: Some questions & requests - by josemendez - 08-08-2022, 02:24 PM
RE: Some questions & requests - by landosilva - 08-08-2022, 02:56 PM
RE: Some questions & requests - by josemendez - 08-08-2022, 03:21 PM
RE: Some questions & requests - by landosilva - 08-08-2022, 03:44 PM
RE: Some questions & requests - by josemendez - 08-08-2022, 03:46 PM
RE: Some questions & requests - by landosilva - 09-08-2022, 04:51 PM
RE: Some questions & requests - by josemendez - 10-08-2022, 07:18 AM
RE: Some questions & requests - by landosilva - 10-08-2022, 10:03 AM
RE: Some questions & requests - by josemendez - 10-08-2022, 10:15 AM
RE: Some questions & requests - by josemendez - 10-08-2022, 10:39 AM