Adding pin constraint to particle in runtime. - 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: Adding pin constraint to particle in runtime. (/thread-229.html) |
Adding pin constraint to particle in runtime. - aaamarkin - 08-11-2017 Hi. I have existing rope with couple on handlers on both of rope ends (attached to first and last rope particle). I want to substitute them (or possibly only one of them with pin constraint). I think handle can be removed/added with the help of disabling/enabling handle gameObject. For adding ping constraint I'm launching some variations of following coroutine: Code: private IEnumerator AttachHook(){ I was experimenting with Adding/Removing from solver and with pushing data back to solver without success. I can see generated with script pin constraint in unity inspector, but it does nothing. What am I missing? Should I reinitialize rope somehow? Thanks a lot. RE: Adding pin constraint to particle in runtime. - niZmo - 08-11-2017 The handle class has public methods to let you add/remove particles. With your pin code, all I see that is weird is why you are calling RemoveConstaint(0) and using the particleHandle to get the first partcle. You may also access the PinConstraints by obiRope.PinConstraints. If you want there is this snippet which keeps track of the pinned particles to remove them later. And also you can use this to get the actual beginning and ending particles of the rope. RE: Adding pin constraint to particle in runtime. - aaamarkin - 09-11-2017 (08-11-2017, 11:20 PM)niZmo Wrote: The handle class has public methods to let you add/remove particles. With your pin code, all I see that is weird is why you are calling RemoveConstaint(0) and using the particleHandle to get the first partcle. You may also access the PinConstraints by obiRope.PinConstraints. If you want there is this snippet which keeps track of the pinned particles to remove them later. And also you can use this to get the actual beginning and ending particles of the rope. RemoveConstaint(0) line is commented out. I just experimented with it. And I'm using particleHandle to get the actual particle that is used by some handler I'm interested in. In general case it could be any particle. I'm using handler just for grabbing particle index. RE: Adding pin constraint to particle in runtime. - niZmo - 09-11-2017 (09-11-2017, 12:09 AM)aaamarkin Wrote: RemoveConstaint(0) line is commented out. I just experimented with it. Oh i didn't see the // lol. And now i see the other code that's commented out that you need. Try to remove the particle from the particle handle first with RemoveParticle(index), then pin the particle. Look at the first link snippet i sent you, to see what methods you need to call before and after. You have them in there already, RemoveFromSolver and PushDataToSolver. More info here. RE: Adding pin constraint to particle in runtime. - aaamarkin - 09-11-2017 (09-11-2017, 12:57 AM)niZmo Wrote: Oh i didn't see the // lol. And now i see the other code that's commented out that you need. Try to remove the particle from the particle handle first with RemoveParticle(index), then pin the particle. Look at the first link snippet i sent you, to see what methods you need to call before and after. You have them in there already, RemoveFromSolver and PushDataToSolver. My current code: Code: private void AttachHook() 'ObiParticleHandle.RemoveParticle(index)' is working and was really helpfull, thanks. But complete code is not working still. After calling 'obiRope.PinConstraints.AddToSolver(null)' really weird things happen. I am not sure how to describe it but rope starts moving up and down super fast, looks like it has infinite length. When I comment 'obiRope.PinConstraints.AddToSolver(null)' line rope behaves ok. But again while I can see newly created PinConstraint in unity inspector rope behaviour looks like no particle has PinConstraint attached. |