Help Linking the positions of actors and other objects - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html) +--- Thread: Help Linking the positions of actors and other objects (/thread-2777.html) |
Linking the positions of actors and other objects - NakanHogeri - 28-02-2021 Currently, I'm trying to place an empty object in each of the two Obi Rope's approximate centers in the same solver. Hierarchy is as follows. Code: □Obi Solver The following script is pasted on each rope. Code: ObiActor actor; For the "public GameObject pointObject" part, I manually put pointObject1 in rope1 and pointObject2 in rope2 from the Inspector. When this is done, the center of rope2 and pointObject1 will move in tandem, and pointObject2 will not move from its original position, which is a strange state. How can I get each pointObject to work with the center of each rope? Sorry for always a beginner question. Thank you. RE: Linking the positions of actors and other objects - josemendez - 28-02-2021 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! RE: Linking the positions of actors and other objects - NakanHogeri - 01-03-2021 Thank you for your polite reply! It worked perfectly. Thank you very much. |