Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Linking the positions of actors and other objects
#2
Hi there!

You're accessing the same particle for both ropes:
Code:
var position = actor.solver.positions[ropeCenterIndex];

To picture why this is wrong, let's pretend each rope has 10 particles. The first rope uses particles 0-9 in the solver, and the second one uses particles 10-19. Remember that each actor contains the indices of its particles in the solverIndices array, so the solverIndices array will contain values 0-9 for the first particle and 10-19 for the second one.

ropeCenterIndex will be 10/2 = 5, for both ropes. You're accessing the particle at position 5 in the solver, which belongs to the first rope. So both ropes will access the same particle (5), since ropeCenterIndex has the same value for both ropes.

you want to do this instead:
Code:
var position = actor.solver.positions[actor.solverIndices[ropeCenterIndex]];

This way, the first rope accesses particle 4, and the second rope accesses particle 14. Does this make sense?

cheers!
Reply


Messages In This Thread
RE: Linking the positions of actors and other objects - by josemendez - 28-02-2021, 07:20 PM