Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Teleporting Rope
#1
Tangentially related to my previous thread (here), but ultimately a different issue, so I decided to make a new topic;

Is there a way to teleport the rope, essentially 'resetting' it at a new position during runtime?

I mentioned my current set up in the previous thread (this post), where the rope object is connected to two anchors, which are then connected to two external game objects. My current attempt teleport all these components, the anchors and game objects teleport fine, but the rope then flies towards them to catch up, causing high velocities and undesired effects.

Cheers!


EDIT:

Seems I was a bit quick to post here! The solution I found was calling the aptly named 'ResetActor()' method in ObiRope.

Should anyone else want it, my implemented solution is as follows;

Code:
    /// <summary>
    /// Moves all components of the rope by a set amount
    /// </summary>
    /// <param name="distanceToMove">The distance to move the rope parts</param>
    public void MoveRopeByAmount(Vector3 distanceToMove)
    {
        //Wire points are the anchor objects
        //Target points are the connector gameobjects attached to the anchors
        for (int i = 0; i < targetPoints.Length && i < wirePoints.Length; i++)
        {
            targetPoints[i].transform.position += distanceToMove;
            wirePoints[i].transform.position += distanceToMove;
        }
        ObiRope.transform.position += distanceToMove;
        ObiRope.ResetActor();

        //Custom method to reset velocity of the rope & it's components
        ResetVelocity();
    }
I'm hoping there's no negative repercussions to using this method I'm unaware of?
Reply
#2
(10-07-2017, 01:56 PM)PhantomBadger Wrote: Tangentially related to my previous thread (here), but ultimately a different issue, so I decided to make a new topic;

Is there a way to teleport the rope, essentially 'resetting' it at a new position during runtime?

I mentioned my current set up in the previous thread (this post), where the rope object is connected to two anchors, which are then connected to two external game objects. My current attempt teleport all these components, the anchors and game objects teleport fine, but the rope then flies towards them to catch up, causing high velocities and undesired effects.

Cheers!



EDIT:

Seems I was a bit quick to post here! The solution I found was calling the aptly named 'ResetActor()' method in ObiRope.

Should anyone else want it, my implemented solution is as follows;


Code:
    /// <summary>
    /// Moves all components of the rope by a set amount
    /// </summary>
    /// <param name="distanceToMove">The distance to move the rope parts</param>
    public void MoveRopeByAmount(Vector3 distanceToMove)
    {
        //Wire points are the anchor objects
        //Target points are the connector gameobjects attached to the anchors
        for (int i = 0; i < targetPoints.Length && i < wirePoints.Length; i++)
        {
            targetPoints[i].transform.position += distanceToMove;
            wirePoints[i].transform.position += distanceToMove;
        }
        ObiRope.transform.position += distanceToMove;
        ObiRope.ResetActor();

        //Custom method to reset velocity of the rope & it's components
        ResetVelocity();
    }
I'm hoping there's no negative repercussions to using this method I'm unaware of?

If you just want to re-start the simulation when moving the rope, this is fine.

There's however the possibility of doing this: just disable the rope, move it to a new place, yield WaitForFixedUpdate() (so that Obi has time to recognize that you moved the rope!), and re-enable it Sonrisa. Simpler, and you simulation won´t be reset upon teleportation.
Reply
#3
(14-07-2017, 07:02 PM)josemendez Wrote: If you just want to re-start the simulation when moving the rope, this is fine.

There's however the possibility of doing this: just disable the rope, move it to a new place, yield WaitForFixedUpdate() (so that Obi has time to recognize that you moved the rope!), and re-enable it Sonrisa. Simpler, and you simulation won´t be reset upon teleportation.

I did try this approach initially, however, it gave me undesirable outcomes as the rope was often in the incorrect position, or the rope's origin would move, but the rope itself would not. The behaviour seemed quite inconsistent infact, for example;

When Teleporting whilst holding the rope, the above method would work a treat. However, when the rope was in Position A and I wanted to reset it to the state it was in when I started the application, moving/Resetting the actor was insufficient (And ResetActor often placed the rope in the incorrect position), and so I had to devise a much more complex method using ObiRope.GeneratePhysicRepresentationForMesh() as the backbone, reapplying the pin constraints as needed once complete.
Reply