Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove Initial Target Offset: Attachments
#2
(13-04-2023, 04:19 PM)Renman3000 Wrote: Hi, 
I have a single rope and two Particle Attachments. 

My issue is that if the Transforms of the Target, for the ObiParticleAttachment are not at the exact position of the ends of the rope, then obi rope does not update to the target position, but the target position + that initial offset. 

Can I snap the rope particle group, attachment position to the target position, in other words, remove the offset? 


Thank you
Hi!

This is the intended behavior, as explained in the manual:
http://obi.virtualmethodstudio.com/manua...ments.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.

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.

If you want to remove the offset, you have to either:
A) move the target transform to the attachment position.
B) move the attached particle to the target transform's position.

Or any combination of both (move both the attached particle and the transform to their average position, for instance). Afterwards, create the attachment.

You can get/set individual particle positions using the particles API, and you can retrieve the index of the particles involved in the attachment by reading the "indices" array of the particle group (In the case of a rope, there's always only one particle per particle group).

kind regards,
Reply


Messages In This Thread
RE: Remove Initial Target Offset: Attachments - by josemendez - 14-04-2023, 07:50 AM