![]() |
|
Best way to disable then reenable rope? - 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: Best way to disable then reenable rope? (/thread-4603.html) |
Best way to disable then reenable rope? - Bopter - 23-03-2026 Hi all! I'm making a game where you try to throw lassos at other players. This requires a lot of spawning a rope, despawning it, then respawning it again. Currently I do this by disabling the ObiRope and ObiRopeExtrudedRenderer components. When I need it again I reenable it by waiting until the rope is loaded then manually adjust the positions, prevPositions, and Velocities of all particles. Then I wait one frame to let things settle before reenabling the Renderer. This almost works, except for a single frame where the Renderer shows its previous position. I cannot for the life of me figure out how to make the Renderer only show the new position of the rope rather than starting at its previous position. This also happens when I just leave the Renderer on the entire time. Is there a better way to go about disabling/enabling rope or some kind of RendererRefresh I can call? I was considering teleporting the rope somewhere far away while disabled rather than disabling the component but wanted to see if there was a better way first. Thanks! Pic of the one frame issue: ![]() Code: // sets up the rope when reenabledRE: Best way to disable then reenable rope? - chenji - 24-03-2026 I will not recreate rope if I develop this game. Just move the existing rope to a position that is not visible to players. (and disable Obi simulation after that) RE: Best way to disable then reenable rope? - josemendez - 24-03-2026 (Yesterday, 08:06 PM)Bopter Wrote: When I need it again I reenable it by waiting until the rope is loaded then manually adjust the positions, prevPositions, and Velocities of all particles. Then I wait one frame to let things settle before reenabling the Renderer. Hi! Physics in Unity are updated in FixedUpdate(). This is often called less frequently than Update(), so simply waiting for the next frame using yield return null is incorrect: you must use yield return new WaitForFixedUpdate(), then wait for the next frame so that rendering is updated. Otherwise the rope will appear in the pose it had during the last FixedUpdate() call before disabling it since no calls to FixedUpdate may take place during the frame where you enable it, so neither simulation or the shape of the rope will be updated. kind regards |