Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Rope extension, vibration and collision
#9
(27-04-2025, 10:28 PM)josemendez Wrote: “M” and “normalizedCoord” in my previous message represent the same value.


Just divide the index of the particle by the total amount of active particles in the rope. This will give you a value in the 0-1 range.

Kind regards,

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;
Vector2 contactPoint = solver.positions[particleIndex] + contact.normal * contact.distance;


int activeParticleCount = rope.activeParticleCount;

float mu = 0;

if (activeParticleCount > 1)
     mu = (float)particleIndex / (activeParticleCount-1);

col.GetComponent<Item>().muValue =(mu);

Debug.Log("mu: " + mu);


   

Even if I try it in reverse as "1f-mu", I can't get the result I want.

As an additional question, I am extending this rope and I need to reset it to its initial state at the end of the game. How can I proceed?
Reply


Messages In This Thread
RE: Rope extension, vibration and collision - by 0hsyn1 - 28-04-2025, 06:38 AM