Obi Official Forum
Help prevent dynamic attachment from disjointing on re-enable - 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 prevent dynamic attachment from disjointing on re-enable (/thread-4280.html)



prevent dynamic attachment from disjointing on re-enable - rystills - 06-07-2024

I have a scene set up similarly to the chain sample scene, with a chain attached statically to the ceiling at one end, and dynamically to a rigidbody at the other. In the editor they appear like:
[attachment=2134]

Upon running the game with gravity disabled on the body, the chain is stretched down a bit:
[attachment=2133]

If gravity is enabled on the dynamic body, the chain stretches down further, and the body becomes slightly disjointed from the chain:
[attachment=2132]

Each time the root object containing the solver, chain, and body is disabled and subsequently reenabled, the body becomes further disjointed by the same amount:
[attachment=2131][attachment=2130]

This behavior can be replicated by manually disabling / enabling the chain and ball while running the chain sample scene. In my case, I can compensate for the initial disjoint by shifting the body up slightly in the editor, but I'm having trouble preventing the further disjoint on re-enable. Is there a recommended way to prevent/mitigate this behavior?


RE: prevent dynamic attachment from disjointing on re-enable - josemendez - 08-07-2024

(06-07-2024, 11:34 AM)rystills Wrote: Each time the root object containing the solver, chain, and body is disabled and subsequently reenabled, the body becomes further disjointed by the same amount:

This is the intended behavior, as explained the manual:
http://obi.virtualmethodstudio.com/manual/6.3/attachments.html

Quote:It's important to realize that attachments do not move the particle group to the position of the target object, nor the target object to the position of the particle group. Moving the particle group to the target's position would collapse all particles into a single point, and would result in a kickback effect once the particles spring back to their original positions. Moving the target could cause a whole palette of issues depending on your game logic.

Instead, particles in the group are attached at their current position relative to the target object. This makes it simple to work with multiple particles, and ensures smooth attachments with no initial "jumps" or sudden motions.

Anytime an attachment is enabled, it attaches the particle group and the target at their current relative position. It won't move either of them, to prevent either adding unwanted energy to the simulation or moving a transform that might break your game's logic. In case you want the attachment to move either the particle group to a specific point on the target transform - or the target transform to the position of a particle in the group, the solution is to do it yourself before re-enabling the attachment:

Quote:If you want particles attached at a specific position other than their position at the time of creating the attachment, you can set their position at runtime before creating the attachment: see scripting particles.

let me know if you need further help,

kind regards


RE: prevent dynamic attachment from disjointing on re-enable - rystills - 09-07-2024

(08-07-2024, 12:10 PM)josemendez Wrote: This is the intended behavior, as explained the manual:
http://obi.virtualmethodstudio.com/manual/6.3/attachments.html


Anytime an attachment is enabled, it attaches the particle group and the target at their current relative position. It won't move either of them, to prevent either adding unwanted energy to the simulation or moving a transform that might break your game's logic. In case you want the attachment to move either the particle group to a specific point on the target transform - or the target transform to the position of a particle in the group, the solution is to do it yourself before re-enabling the attachment:


let me know if you need further help,

kind regards
Thanks! I was setting the attachment target to null before updating the transform, but the transform would revert back after I reassigned the target. I took your suggestion and disabled the attachment rather than clearing its target before transforming it, and that worked as expected.