Obi Official Forum
Help Teleporting rope across scene causes rope to behave like slingshot) - Printable Version

+- Obi Official Forum (http://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (http://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (http://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Help Teleporting rope across scene causes rope to behave like slingshot) (/thread-2452.html)



Teleporting rope across scene causes rope to behave like slingshot) - mandark83 - 28-08-2020

Hi,

We are using a player character equipped with a harness and a rope with 2 hooks attached to the harness.
The player can attach/detach for safety on various objects in the scene.

When switching between scenarios, we teleport the player and his gear to other parts of the scene.

When we translate(teleport) the player, his harness and hooks appear immediately in the correct spot, but
the obi rope starts flying towards the player like a giant slingshot, trying to catchup to the hook endpoints it is attached to.

It happens for a couple of seconds and then everything is ok.

But many times it gets stuck on various geometry in the level.

QUESTION 1: Is there a way I can turn Obi rope off for a small amount of time, move it to the correct destination and then turn back on?

This is our current attempt at solving this issue.

Code:
        public void TeleportRope(Vector3 pos, Vector3 rot, Vector3 rotAxis, float rotDeg)
        {
        ropeEndpointBig.transform.position += pos;
        ropeEndpointBig.transform.RotateAround(rot, rotAxis, rotDeg);

               ropeEndpointSmall.transform.position += pos;
        ropeEndpointSmall.transform.RotateAround(rot, rotAxis, rotDeg);

            rope.enabled = false;
            rope.PullDataFromSolver(ParticleData.POSITIONS);
            rope.PullDataFromSolver(ParticleData.VELOCITIES);

            rope.transform.position += pos;
            rope.transform.RotateAround(rot, rotAxis, rotDeg);

            StartCoroutine(EnableRopeNextFrame());
        }

        private IEnumerator EnableRopeNextFrame()
        {
            yield return null;
            rope.enabled = true;
        }



RE: Teleporting rope across scene causes rope to behave like slingshot) - josemendez - 28-08-2020

Hi,

If the solver is part of the character's hierarchy, there's no need to do any of this as changing the position of the entire character would automatically reposition the rope (since simulation is performed in the solver's local space, as stated in the manual:http://obi.virtualmethodstudio.com/tutorials/obisolver.html). Having the solver as part of the character is also recommended to avoid floating point precision issues.

If the solver is outside the character hierarchy (which isn't a good idea in general), then your script should work. Can you give a bit of context regarding how and when you're calling TeleportRope()?


RE: Teleporting rope across scene causes rope to behave like slingshot) - mandark83 - 28-08-2020

Quote:Hi,

If the solver is part of the character's hierarchy, there's no need to do any of this as changing the position of the entire character would automatically reposition the rope (since simulation is performed in the solver's local space, as stated in the manual:http://obi.virtualmethodstudio.com/tutorials/obisolver.html). Having the solver as part of the character is also recommended to avoid floating point precision issues.

If the solver is outside the character hierarchy (which isn't a good idea in general), then your script should work. Can you give a bit of context regarding how and when you're calling TeleportRope()?


The solver is part of the hierarchy of the character.

[Image: JothSI0.png] https://pasteboard.co/JothSI0.png

Between scene loads we reparent all the gear to a gameObject in a CORE scene (which is never unloaded).
After scene loads, we reparent/equip back the gear to the player.


RE: Teleporting rope across scene causes rope to behave like slingshot) - josemendez - 28-08-2020

(28-08-2020, 04:05 PM)mandark83 Wrote: The solver is part of the hierarchy of the character.

[Image: JothSI0.png]  https://pasteboard.co/JothSI0.png

Between scene loads we reparent all the gear to a gameObject in a CORE scene (which is never unloaded).
After scene loads, we reparent/equip back the gear to the player.

What Obi version are you using?

Would it be possible for you to share your project with us? Ropes should definitely not sling around if the solver is translated together with the character.