Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Rope moving in runtime
#1
Hello!

I have a Rope with two static attachments on it's endings. 
I need to periodically show this rope in different places of the scene, between different objects in space. 
I use only one rope, simply turning it and it's attachments off and on when needed (by gameobject.setActive). The problem is that if you turn it on, pause for half a second, for example, and then move the attachments to the desired positions, then everything is ok, rope moves there it should be (with wild stretching, but ok). 

But if you turn it on and immediately give the attachments new positions, then the rope don't moves from its place.

What is the best way to move the attachments (these are ordinary empty Transforms) so that the rope immediately moves to the desired place and stays there until the next turn off?
Reply
#2
(02-12-2024, 02:46 PM)Apoll0 Wrote: Hello!

I have a Rope with two static attachments on it's endings. 
I need to periodically show this rope in different places of the scene, between different objects in space. 
I use only one rope, simply turning it and it's attachments off and on when needed (by gameobject.setActive). The problem is that if you turn it on, pause for half a second, for example, and then move the attachments to the desired positions, then everything is ok, rope moves there it should be (with wild stretching, but ok). 

But if you turn it on and immediately give the attachments new positions, then the rope don't moves from its place.

What is the best way to move the attachments (these are ordinary empty Transforms) so that the rope immediately moves to the desired place and stays there until the next turn off?

Hi!

Attachments won't force the rope particles to move to a specific location, but attach them in the position they're in at the time of enabling the attachment as explained in the manual: http://obi.virtualmethodstudio.com/manua...ments.html

If you want to force  a specific attachment position, there's a code snippet in the manual that achieves just that: http://obi.virtualmethodstudio.com/manua...ments.html

(02-12-2024, 02:46 PM)Apoll0 Wrote: then everything is ok, rope moves there it should be (with wild stretching, but ok). 

Probably you'd want to Teleport() the rope (in addition to moving the attachments) to get rid of the stretching? Note that moving the transform of a rope has no effect on it while it's being simulated: you need to move its particles - which is what Teleport() does.

kind regards,
Reply
#3
(02-12-2024, 02:55 PM)josemendez Wrote: Hi!

Attachments won't force the rope particles to move to a specific location, but attach them in the position they're in at the time of enabling the attachment as explained in the manual: http://obi.virtualmethodstudio.com/manua...ments.html

If you want to force  a specific attachment position, there's a code snippet in the manual that achieves just that: http://obi.virtualmethodstudio.com/manua...ments.html


Probably you'd want to Teleport() the rope (in addition to moving the attachments) to get rid of the stretching? Note that moving the transform of a rope has no effect on it while it's being simulated: you need to move its particles - which is what Teleport() does.

kind regards,
Hello!
Thanx!
Seems, that "If you want to force  a specific attachment position, there's a code snippet in the manual that achieves just that:" is what I want. I will try it.

And BTW teleport doesn't help because I need not only move the rope itself but also change the positions of it's ends.
Reply
#4
(02-12-2024, 04:49 PM)Apoll0 Wrote: And BTW teleport doesn't help because I need not only move the rope itself but also change the positions of it's ends.

You should both teleport the rope and change the attachments position. Moving the rope's transform doesn't affect its particles at all, which is why the rope is stretching towards the new position of the attachments.

regards,
Reply
#5
I tried and it is not working
So, I'll try to explain with pic

I have some objects. A, B, C, D

Initially the rope attached to objects A and B (with Obi Attachment). Then I need to disable it and after some time to enable it attached to C and D.
I change targets and then enable the rope again. It appears as yellow line and after some moments it sets as aspected. Is there a way to appear it as dashed blue line at once?

My be I need to change positions of all rope particles? Not the ends only?


Attached Files Thumbnail(s)
   
Reply
#6
(03-12-2024, 04:48 PM)Apoll0 Wrote: Is there a way to appear it as dashed blue line at once?
My be I need to change positions of all rope particles? Not the ends only?

Yes you need to do that, that's exactly what I was trying to tell you in my previous responses: you should use rope.Teleport() (which changes the position of all rope particles) in addition to moving the attached targets.

kind regards,
Reply