12-01-2022, 08:55 AM
(This post was last modified: 12-01-2022, 09:38 AM by josemendez.)
(11-01-2022, 03:30 AM)almog1752 Wrote: i had alot of problems but the main one i have now and cant solve is i cant get the rope curses to extend the way i want it to,here my code:
Hi!
I'd need to at least know what the problem is, or why the way this works isn't the way you want it to. Otherwise I don't know what to do to test this!

However I can see an issue in your code: you're assuming particle indices are consecutive, which is only true if the rope is never cut or resized. You're using a cursor, so you cannot assume this. The following code:
Code:
int solverIndex = actor.solverIndices[actor.activeParticleCount - 1];
Vector3 LastPoint = SolverComponent.positions[solverIndex];
Doesn't return the last particle in the rope, as implied. When you change the length of a rope using a cursor, particles are appended to the rope at different places (depending on where the cursor is placed) so the last particle in the solverIndices[] array might be in the middle of the rope or even at the beginning. In these circumstances, you need to use rope elements. These are the "links" in-between particles, and are always guaranteed to be consecutive. Each element joins two particles. So the first particle in the rope is the first particle of the first element, and the last particle in the rope is the second particle of the last element. Like this:
Code:
var LastPoint = SolverComponent.positions[rope.elements[rope.elements.Count-1].particle2];
kind regards,