CharacterBody2D based grappling hook

Godot Version

4.2.1

Question

I’m trying to make a CharacterBody2D based grappling hook similar to this video. https://www.youtube.com/shorts/l2KyzX6NHQQ
I was trying to figure it out for a couple of days but I’m still stuck. Could someone help me with it?