Help Finding last point of rope - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html) +--- Thread: Help Finding last point of rope (/thread-3177.html) |
RE: Finding last point of rope - srid96 - 18-11-2021 Hi Again , So I am using Tear() function to rope am using, once the rope is torn how to find last point of new torn rope(first rope). My rope is attached to a gameobject which moves, so also, once rope is torn, how to ignore second rope completely (it drags since its parented to that gameobject) RE: Finding last point of rope - josemendez - 18-11-2021 (18-11-2021, 02:39 PM)srid96 Wrote: Hi Again , Hi! You can detect all torn points by simply iterating trough rope elements until you find an element such that: Code: element.particle2 != nextElement.particle1 (18-11-2021, 02:39 PM)srid96 Wrote: My rope is attached to a gameobject which moves, so also, once rope is torn, how to ignore second rope completely (it drags since its parented to that gameobject) Keep in mind that simulation is always performed in the solver's local space. From the manual: Quote:Solvers always perform the simulation in local space. This means that translating, rotating or scaling the solver will rigidly transform the simulation as a whole. The torn bit of rope should not move unless you're simulating in the rope's local space (that is, you placed the ObiSolver and the ObiRope in the same object). Simply place the solver outside the object's hierarchy. kind regards, RE: Finding last point of rope - srid96 - 18-11-2021 (18-11-2021, 02:48 PM)josemendez Wrote: Hi! My rope resizes its length over time, so by ignoring I mean getting rid of that part . So, when torn, rope length from the first piece resizes. Taking out solver from object's hierarchy does the trick for the torn piece not to follow, when rope's particle attachment target set to that object. Doing this, rope length's reduces the torn piece first and then first piece. But i am focusing only on first piece. RE: Finding last point of rope - josemendez - 19-11-2021 (18-11-2021, 04:07 PM)srid96 Wrote: My rope resizes its length over time, so by ignoring I mean getting rid of that part . So, when torn, rope length from the first piece resizes. Depends on where you place the cursor. If you place it at a particle in the first piece, it will resize the first piece. You can place cursors anywhere along the rope, oriented in either direction. RE: Finding last point of rope - srid96 - 19-11-2021 am calculating rope' length in update function, if its less than 1, my game is over, something like that. Thats why i need to get rid of the torn piece, as in it doesn't depend on anything, not just resizing from cursor point. Sorry i wasnt clear. RE: Finding last point of rope - josemendez - 19-11-2021 (19-11-2021, 10:14 AM)srid96 Wrote: am calculating rope' length in update function, if its less than 1, my game is over, something like that. Thats why i need to get rid of the torn piece, as in it doesn't depend on anything, not just resizing from cursor point. Sorry i wasnt clear. Oh, ok. You can just remove the elements in the second piece, deactivating all particles referenced by these elements by calling rope.DeactivateParticle(index) and passing the index of the particle in the rope. RE: Finding last point of rope - srid96 - 19-11-2021 (19-11-2021, 10:22 AM)josemendez Wrote: Oh, ok. You can just remove the elements in the second piece, deactivating all particles referenced by these elements by calling rope.DeactivateParticle(index) and passing the index of the particle in the rope.For Tearing Code : Code: // check rope elements and tear the one that references this particle: For deactivation of particles in second piece: Code: private void DeactivateTornParticles(int particleIndex) rope doing something weird, its like trying attach the cut portion, stretches long RE: Finding last point of rope - josemendez - 19-11-2021 (19-11-2021, 11:29 AM)srid96 Wrote: You're mixing up particles and elements again: it does not make sense to iterate from particleIndex to the number of elements. There's a different number of elements than particles, and they're in different order. Element number 6 in the elements array might reference particles 24 and 65. You can't assume particle #6 is part of element #6. Iterate trough elements past the (elm.particle2 == particleIndex) one, and for each element deactivate both particles. Then remove all those elements from the elements array. RE: Finding last point of rope - srid96 - 19-11-2021 Could you explain it in code, that would help me understand better RE: Finding last point of rope - josemendez - 19-11-2021 (19-11-2021, 11:54 AM)srid96 Wrote: Could you explain it in code, that would help me understand better It's basic programming stuff, really: remove the break; instruction (so that the loop continues after finding the cut), then for every element after the cut call DeactivateParticle on both its particles, and mark the element to later destroy it (for instance, by adding it to a list of elements to destroy). Then for all elements marked for destruction, remove them from the rope.elements array. In code: Code: // check rope elements and tear the one that references this particle: This is untested but should work. Note that removing the part of the rope after the cut immediately will make it look like the rope just got shorter. It would look better if you stored the cut element, and after some time removed the bit of the rope that was cut off. |