04-02-2018, 03:38 AM
Hello,
Thank you for the suggestion, changing the resolution does seem to help a lot although I'm concerned about the impact on collision detection which I haven't been able to test yet.
Changing the resolution also was not a perfect solution and it's still too elastic, so I was trying your suggestion of tethering everything to the fixed particle.
for (int j = rope.UsedParticles-1; j >= 0; j--){
float dist = rope.InterparticleDistance * j;
tetherBatch.AddConstraint(j,0,dist,1,1);
}
I have no idea how I'm supposed to write this but my approach above does not work because when you extend the rope with cursor the indices do not stay in order (IE the particle with index 1 stops being the next particle after the fixed particle.) How am I supposed to do this?
Additionally although I haven't been able to test either yet - why do you recommend tethering each particle to the fixed particle instead of tethering each particle to the preceding particle?
Side note for anyone reading this: advancing the coroutine that creates the rope manually with movenext was suggested in case it was mandatory to perform certain rope functions on the same frame the rope is created. Doing this is not hard but I'm hoping that by posting the code I can save someone the few hours of research and guessing it took.
IEnumerator ienumerator = rope.GeneratePhysicRepresentationForMesh();
while(!rope.Initialized) {
ienumerator.MoveNext();
}
I have not been able to observe any performance consequence / frame drop from doing this. The alternative is to, in every one of your functions that does anything with the rope, either check if rope is initialized and return if not, or set every one of them up as their own coroutine that waits for the rope to be initialized - either one of which creates huge bug potential.
Thanks,
Jon
Thank you for the suggestion, changing the resolution does seem to help a lot although I'm concerned about the impact on collision detection which I haven't been able to test yet.
Changing the resolution also was not a perfect solution and it's still too elastic, so I was trying your suggestion of tethering everything to the fixed particle.
for (int j = rope.UsedParticles-1; j >= 0; j--){
float dist = rope.InterparticleDistance * j;
tetherBatch.AddConstraint(j,0,dist,1,1);
}
I have no idea how I'm supposed to write this but my approach above does not work because when you extend the rope with cursor the indices do not stay in order (IE the particle with index 1 stops being the next particle after the fixed particle.) How am I supposed to do this?
Additionally although I haven't been able to test either yet - why do you recommend tethering each particle to the fixed particle instead of tethering each particle to the preceding particle?
Side note for anyone reading this: advancing the coroutine that creates the rope manually with movenext was suggested in case it was mandatory to perform certain rope functions on the same frame the rope is created. Doing this is not hard but I'm hoping that by posting the code I can save someone the few hours of research and guessing it took.
IEnumerator ienumerator = rope.GeneratePhysicRepresentationForMesh();
while(!rope.Initialized) {
ienumerator.MoveNext();
}
I have not been able to observe any performance consequence / frame drop from doing this. The alternative is to, in every one of your functions that does anything with the rope, either check if rope is initialized and return if not, or set every one of them up as their own coroutine that waits for the rope to be initialized - either one of which creates huge bug potential.
Thanks,
Jon