Help Rope moving in runtime - 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 Rope moving in runtime (/thread-4419.html) |
Rope moving in runtime - Apoll0 - 02-12-2024 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? RE: Rope moving in runtime - josemendez - 02-12-2024 (02-12-2024, 02:46 PM)Apoll0 Wrote: Hello! 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/manual/7.0/attachments.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/manual/7.0/scriptingattachments.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, RE: Rope moving in runtime - Apoll0 - 02-12-2024 (02-12-2024, 02:55 PM)josemendez Wrote: Hi!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. RE: Rope moving in runtime - josemendez - 03-12-2024 (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, RE: Rope moving in runtime - Apoll0 - 03-12-2024 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? RE: Rope moving in runtime - josemendez - 03-12-2024 (03-12-2024, 04:48 PM)Apoll0 Wrote: Is there a way to appear it as dashed blue line at once? 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, |