Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Add force to particle

I have the next scenario:

One ObiSolver that contains a few ropes. What I want is that once I cut one of that ropes (using the ObiRope.Tear function), I want to apply a certain amount of force to each extreme of the particles in order to add some juice to the cut action.

In the past, I was using ObiSolver.externalforces, using as an index the element that contains the particle that I get from e.contacts (being e ->ObiSolver.ObiCollisionEventArgs). At that time I was using One ObiSolver per rope so there wasn't any problem.

Now I'm using one ObiSolver for different ropes. Is there any way to get the global number of the element that contains the particle?
Because if I'm using the old way the force is applied to a different rope than the one that I'm tearing it.

Don't pass an element index to the solver arrays, as elements != particles. This won't work if there is more than one actor in the solver, and won't work in the general case of resized/torn ropes. If it worked before, it's just luck.

Rope elements contain the indices of both particles at its ends, you should be able to use that.

solver.externalForces[element.particle1] = <your force>;
solver.externalForces[element.particle2] = <your force>;