Creating a double sided zipline?

I have two cube objects placed at point A and point B with a cylinder object (capsule collider attached and trigger ON) acting as the zipline. I have a basic script attached to the cylinder where if I press a key it will get the player movement script, and a coroutine starts.

// Player movement snippet
public Vector3 positionToMoveTo;

public void MoveOnZipline()
    {
        StartCoroutine(LerpPosition(positionToMoveTo, 5));
    }

    IEnumerator LerpPosition(Vector3 targetPosition, float duration)
    {
        float time = 0;
        Vector3 startPosition = transform.position;
        while (time < duration)
        {
            transform.position = Vector3.Lerp(startPosition, targetPosition, time / duration);
            time += Time.deltaTime;
            yield return null;
        }
        transform.position = targetPosition;
    }

There are several issues, but the main problem is that I have to manually add the destination via Vector3 positionToMoveTo (point B is the destination) to my player inspector. With this, my character moves along the zipline and reaches the destination just fine.

But if I want to come back down, I need to add yet another Vector3 to my player inspector which will just clutter it and if I decide to add multiple ziplines to my game, my inspector will be full of positions which I know is not the way to do this.

I thought Lerp was the solution here with a coroutine but it prevents me from going both down and up the zipline. Is there another method to solve this (I’m using the in-built CC)? I have been trying to use the direction my player is facing to just move until it reaches the end of the zipline object but I haven’t got that to work.

Ziplines are just a special form of a path, or list of waypoints.

Yes, you could double-author each one into two ziplines, one each way, but I agree, that’s gross.

When I did my waypointing I used this approach:

Check out the CloneToInversePath boolean… if checked then at runtime it clones a waypoint list, reverses it, and resubmits it as yet another possible path.

This way you would author a zipline once but when the game runs there would be two ziplines, one to take you from A to B, one to take you from B to A.

… and best of all, no other code changes!

If you have a curvy zipline, I recommend SURGE on the asset store. It’s free and includes a super-easy spline solver. You could probably do your whole zipline movement with just a few lines of code.