Zipline in Godot

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Huawi

Hey guys, im fairly new to Godot and i was wondering if there is a way of making a 2D platformer zipline for my character?

I have been trying things such as portals, grappling guns and nothing really works the way i want it to?
so if you have an idea of how to make it, it would be cool if you could share it :smiley:

:bust_in_silhouette: Reply From: Mario

A bit condensed, to save on typing and give you a general idea, but if you’d need a more elaborate answer – since I think this is kind of an interesting/good question – let me know.

First, I’d setup the zip-line:

  • Create a Path2D representing the zip-line. You might possibly want to draw it some way, too.
  • Add a PathFollow2D node as a direct child.

And that’s the whole setup already!

Now to let your character enter the zipline (at the start position), you just move your player to be a child of the PathFollow2D node created above.

Now animate the unit_offset property of the PathFollow2D from 0.0 to 1.0 or from 1.0 to 0.0 to animate the sliding effect. You can also use offset to move in regular units (typically pixels) along the path.

To get off the zipline, just reparent your player once more.

If your characters has to hop on (or hop off) somewhere along the zipline, you can figure this out with some of the helper functions provided by the Path2D node.