Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  ReattachingParticle
#1
Good day,

Sometimes my particle, which attached to object shifts from said objects and tries to stay on this shifted position from object due to attachment.

I tried to return it on previous position using ObiRope.TeleportParticle if it shifts, but attachment seems to save this shift somewhere and returns particle back...

How to reset Attachment after teleport?

Now made Attachments Bind Function public and rebind attachment- seems to work, but now I need to set said particle right Orientation- how to do it? And is my Bind workaround legid or not?
Reply
#2
(21-02-2022, 04:08 PM)alex798 Wrote: Good day,

Sometimes my particle, which attached to object shifts from said objects and tries to stay on this shifted position from object due to attachment.

I tried to return it on previous position using ObiRope.TeleportParticle if it shifts, but attachment seems to save this shift somewhere and returns particle back...

How to reset Attachment after teleport?

Now made Attachments Bind Function public and rebind attachment- seems to work, but now I need to set said particle right Orientation- how to do it? And is my Bind workaround legid or not?

Hi there,

The usual approach would be to just teleport the attachment together with the actor/particle(s). Otherwise you will end up with a rope that's far away from the object/place where it should be attached, which will cause a large whiplash force as the attached particle tries to get back into place and pulls the rest of the actor with it.
Reply
#3
(24-02-2022, 08:53 AM)josemendez Wrote: Hi there,

The usual approach would be to just teleport the attachment together with the actor/particle(s). Otherwise you will end up with a rope that's far away from the object/place where it should be attached, which will cause a large whiplash force as the attached particle tries to get back into place and pulls the rest of the actor with it.

Hi,

Thanks, but how it's done programmically- Now I do this in update and check if group separates for example 1sm- so reattachment is not so far but rotation is off, and distance is not ideal...

How to teleport and rotate attachment?- if this can be done I won't teleport particicles (cause it hinders nearby particles) and just return target to place...
Reply
#4
(09-03-2022, 02:11 PM)alex798 Wrote: Hi,

Thanks, but how it's done programmically- Now I do this in update and check if group separates for example 1sm- so reattachment is not so far but rotation is off, and distance is not ideal... How to teleport and rotate attachment?- if this can be done I won't teleport particicles (cause it hinders nearby particles) and just return target to place...

Targets are just regular Unity objects, so you teleport them by simply setting their position and/or rotation:

Code:
object.transform.position = <new position>;
Reply
#5
(09-03-2022, 02:51 PM)josemendez Wrote: Targets are just regular Unity objects, so you teleport them by simply setting their position and/or rotation:

Code:
object.transform.position = <new position>;
No, I mean if I move target won't attached particles move with it?  Or they move only with Physics(Rigidbody) movements and stay with transforms teleporting?
Reply
#6
(10-03-2022, 09:05 AM)alex798 Wrote: No, I mean if I move target won't attached particles move with it?  Or they move only with Physics(Rigidbody) movements and stay with transforms teleporting?

If the attachment is static, the target transform position and orientation is simply copied to the particle.
If the attachment is dynamic, target transform movement (be it a rigidbody or not) will be applied to the particle as a force, which in turn will move the particle.

Either way if you move the target, any attached particles will move with it.

Note that attachments only attach whatever particle(s) are part of the particle group. So if you have a rope and attach one control point that's only one particle attached, not all particles in the rope. All other particles in the rope will be simulated as usual which means that if you teleport the target -and the attached particle with it- all other particles in the rope will spring towards the target simply because the rope strives to keep its rest length.

If you want to move both the target and the entire rope without any springy motion going on, you want to teleport both.
Reply
#7
(10-03-2022, 09:32 AM)josemendez Wrote: If the attachment is static, the target transform position and orientation is simply copied to the particle.
If the attachment is dynamic, target transform movement (be it a rigidbody or not) will be applied to the particle as a force, which in turn will move the particle.

Either way if you move the target, any attached particles will move with it.
So thats yhe problem- I have dynamic attachment and sometimes there are a slight distance between particle and attached target (which wasn't originally) so I need to move either particles to target or otherwise so that other component stay in place... How can i do this?
Reply
#8
(10-03-2022, 09:39 AM)alex798 Wrote: So thats yhe problem- I have dynamic attachment and sometimes there are a slight distance between particle and attached target (which wasn't originally) so I need to move either particles to target or otherwise so that other component stay in place... How can i do this?

I recently modified the ObiParticleAttachment script for another user that had a similar requirement. You can find the modified script at the end of this thread:

http://obi.virtualmethodstudio.com/forum...age-3.html

Note this works by "cheating", in the sense that the particle is always rendered at a fixed position relative to the target, so it looks like the dynamic attachment is a static one. However the physical location of the particle won't match the visual location.
Reply
#9
(10-03-2022, 09:43 AM)josemendez Wrote: I recently modified the ObiParticleAttachment script for another user that had a similar requirement. You can find the modified script at the end of this thread:

http://obi.virtualmethodstudio.com/forum...age-3.html

Note this works by "cheating", in the sense that the particle is always rendered at a fixed position relative to the target, so it looks like the dynamic attachment is a static one. However the physical location of the particle won't match the visual location.
Looks good, but doubt it's ideal for my case- the least random way to reproduce issue is to disable rope, move target and reanable it- in this case shift stay the same (in more random way is hard to test...) - is it possible to call some function to reattach (or maybe don't update attachment in OnEnable?)
Reply
#10
(10-03-2022, 10:01 AM)alex798 Wrote: Looks good, but doubt it's ideal for my case- the least random way to reproduce issue is to disable rope, move target and reanable it- in this case shift stay the same (in more random way is hard to test...) - is it possible to call some function to reattach (or maybe don't update attachment in OnEnable?)

Ok, I think I understand now. This you're talking about is the intended behavior.

When you disable the rope, or remove the attachment and re-add it, the attachment will automatically call Bind(). What this does is it attaches the rope particle at its current position relative to the target.

If you always want the rope to be attached at a specific point, you want to manually set the particle position and then call Bind() afterwards. Anytime you call Bind(), the particle's current position/orientation will be used as the reference position/orientation to attach it.

This topic was also brought up by another user in this thread, might be helpful:
http://obi.virtualmethodstudio.com/forum...-3344.html
Reply