Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Obi Cloth Particle Attachment
#1
Hi all,

I have an issue regarding Obi Particle Attachments in regards with the Obi Cloth.

I have the setup (as visualized in the attachments) with 3 ObiParticle Attachments
2 attachments are on object X with Particle Group 1
1 attachment is on object Y with Particle Group 2

(i am using Objects at the X and Y position to detect overlap for when it should be attached together, and 1 attachment to switch between the 2 different object to actually snap them together)

When changing the Target manually via the inspector of one of the X Attachments to the same Target as the Y attachment the cloth forms a circle and the position of the particles is snapped together,
this behaviour is what i am looking for but instead of manually setting the Target i want to do the same via script.
Instead of snapping the X particles to the Y particles it seems they keep their positional offset when the Target is changed.

I cannot find the piece of code that would provide this change in behaviour when either setting the Target from the inspector or the Target in the ObiParticleAttachment and would like some help or clarification.

Thanks in advance.
Reply
#2
(21-02-2023, 05:10 PM)BobPrespective Wrote: 2 attachments are on object X with Particle Group 1

Hi there!

Attaching the same particle group multiple times results in undefined behavior, should not be important if both attachments are to the same object though. See:
http://obi.virtualmethodstudio.com/manua...ments.html

Quote:Particles affected by more than one attachment will follow the attachment that was updated last. The update order for attachment is undefined.

(21-02-2023, 05:10 PM)BobPrespective Wrote: When changing the Target manually via the inspector of one of the X Attachments to the same Target as the Y attachment the cloth forms a circle and the position of the particles is snapped together,
this behaviour is what i am looking for but instead of manually setting the Target i want to do the same via script.
Instead of snapping the X particles to the Y particles it seems they keep their positional offset when the Target is changed.

Particles should never change position as a result of updating an attachment, be it via the inspector or programmatically (the code that is called in both cases is the same, doing it trough the inspector just calls the same target setter you'd call in a script). I'm unable to reproduce the behavior you describe when changing the target via the inspector, could it be that there's something else forcing the position of the particles?

Attachments always keep the position of the particles relative to the object they're initially attached to, as well as the position of the object itself. From the manual:

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.

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.

(21-02-2023, 05:10 PM)BobPrespective Wrote: I cannot find the piece of code that would provide this change in behaviour when either setting the Target from the inspector or the Target in the ObiParticleAttachment and would like some help or clarification.

If you want particles to be attached to the object at a different position (eg, you want them to "snap" to the particles in a different particle group) you need to explicitly set their position before enabling the attachment. You do this using the particles API.

The page on scripting attachments should also help: http://obi.virtualmethodstudio.com/manua...ments.html

let me know if I can be of further help,

kind regards
Reply