Help Runtime repin rope to new controll point - 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 Runtime repin rope to new controll point (/thread-2963.html) |
Runtime repin rope to new controll point - yeronimovr - 30-05-2021 Hello, let`s say there are A and B points between which i`m generating a rope. Then i want to add a 3rd C point and then move/repin constraint rope to new C point. Below steps: 1. spawn rope between A-B: two controll points and 2 pin constraints 2. spawn new game object and adding on his transform new controll point using InsertControlPoint Code: Vector3 pointPos = GetSolverLocalPos(hooks[GetLastHookIndex].transform.position); 3. unsap (remove constraint) rope from B: getting rope consraint, getting first batch, removing from batch. set batch to solver, setDirtyConstraints Code: var pinConstraints = rope.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>; and now where im stuck: 4. i want to move rope (all particles to new C point position) forward C - it works Code: for (int i = 0; i < blueprint.activeParticleCount; i++) 5. when i want to pin last particle to C rope the constraint doesnt work and rope is going back with all forces working on particles - stuck here. Code: var pinConstraints = rope.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>; My target is to attach rope to new C point, set there cursor, change rope length that i can again attach rope to B point getting: A-C-B connections. Which steps i`m missing (some update on some component) or what im doing wrong ? Thanks for any help in advance RE: Runtime repin rope to new controll point - josemendez - 31-05-2021 Code: for (int i = 0; i < blueprint.activeParticleCount; i++) This will place all particles in the rope at the exact same position, essentially collapsing the rope in to a point. I guess this is not what you want in this particular case. Not sure what the intent is? When adding the new pin constraint to point C, you set the amount of active constraints to 2, despite only adding 1: Code: batch.activeConstraintCount = 2; Does that batch already contain a constraint that you also want active? Other than this, the code looks ok to me. |