28-04-2025, 08:07 AM
(This post was last modified: 28-04-2025, 08:16 AM by josemendez.)
(28-04-2025, 06:38 AM)0hsyn1 Wrote: I am using this code but I am not getting the result I want, where am I going wrong?
My code;
Code:int particleIndex = contact.bodyA;
contact.bodyA is not a particle index. To get the index of the particle in the actor, use the solver.simplices array and then look up solver.particleInActor to get the index of that particle in the rope. See "Retrieving the particle involved in a contact" in the manual: https://obi.virtualmethodstudio.com/manu...sions.html
(28-04-2025, 06:38 AM)0hsyn1 Wrote: As an additional question, I am extending this rope
If you're altering the topology of the rope in any way (extending/retracting/cutting the rope) the above approach using particles won't work. The reason is that there's no guarantee new particles (added when extending the rope) will be added at the end/start of the rope, so their indices may be unordered. You must use elements instead as explained in the manual: https://obi.virtualmethodstudio.com/manu...ropes.html
The approach is similar: get a particle index from the contact, then iterate over all elements until you find the one that references that particle. Once you have the index of the desired element, divide it by the number of elements in the rope to get the normalized coordinate.
(28-04-2025, 06:38 AM)0hsyn1 Wrote: and I need to reset it to its initial state at the end of the game. How can I proceed?
Simply reloading the original rope blueprint (by assigning it to rope.ropeBlueprint) should do it.
kind regards,