05-03-2021, 12:55 PM
(This post was last modified: 05-03-2021, 12:58 PM by josemendez.)
Hi Martin,
Tested your code, and it works as it's supposed to: attachments work by binding the particle at its current position, relative to the transform they're being bound to. So if you destroy the attachment, let the actor simulate, and then re-create the attachment, the particle will be attached at whenever it is at that moment.
If you need to attach the particle to a specific point in an object's local space, you have several options:
1.- Set the particle position before creating the attachment.
2.- Set the particle position and manually set its inverse mass to 0 (this is what a static attachment does under the hood). Also, see the ObiContactGrabber.cs utility script for an example of how to do this: the contact grabber detects collisions between particles and colliders, then attaches the particle to the collider.
3.- Manually create a pin constraint, passing the offset in local space to the AddConstraint() method.
Let me know if you need further help with any of these.
Tested your code, and it works as it's supposed to: attachments work by binding the particle at its current position, relative to the transform they're being bound to. So if you destroy the attachment, let the actor simulate, and then re-create the attachment, the particle will be attached at whenever it is at that moment.
If you need to attach the particle to a specific point in an object's local space, you have several options:
1.- Set the particle position before creating the attachment.
2.- Set the particle position and manually set its inverse mass to 0 (this is what a static attachment does under the hood). Also, see the ObiContactGrabber.cs utility script for an example of how to do this: the contact grabber detects collisions between particles and colliders, then attaches the particle to the collider.
3.- Manually create a pin constraint, passing the offset in local space to the AddConstraint() method.
Let me know if you need further help with any of these.