Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Teleport attachment to the transform target
#4
(02-03-2022, 02:04 PM)lufydad Wrote: Indeed I am confused between the control point and the particles... Sorry for that ^^
With your remark, I was indeed talking about particles and not about control point. Therefore I rewrite my question : my blueprint is already made and I want to edit the particles positions in runtime and make them teleport to attached transform. Is it more clear ?

Oh ok! Clearer now Sonrisa

Similar to how you'd move a control point, you have to convert from the object's local space to the solver's local space (again, using Unity's transform functions).

Once you have the position you want the particle to be attached to (expressed in solver space), you just set it:

Code:
var solverIndex = rope.solverIndices[attachment.ParticleGroup.particleIndices[0]];
rope.solver.positions[solverIndex] = position;

Now if the attachment component already exists and the simulation is running when you do this, you need to re-bind the attachment so that it picks up the new position. This is done automatically when you change either the particle group or the target, but you might want to call it manually in this case to force it. Since it's a private method, open ObiParticleAttachment.cs and make its Bind() method public.

Then you can call attachment.Bind(); and you're done. This is what tells the attachment "see where the particle is in relation to the object right now? I want it to stay right there".
Reply


Messages In This Thread
RE: Teleport attachment to the transform target - by josemendez - 02-03-2022, 02:14 PM