Hookshot Help

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

Hello, I am making a 2d platform and so far my character can run, idle, jump, and wall jump, but I was wondering how to make a hook shot, where when you press the button the hook goes out horizontally in the direction you are facing and pulls you towards whatever it connects with. Any ideas would be appreciated, thanks.

:bust_in_silhouette: Reply From: njamster

Attach a RayCast2D to your player-character, pointing in it’s horizontal view direction. When pressing the hookshot-button set it’s enabled-property to true, then get the collision point with get_collision_point and move the player towards it. You could visualize it using a Line2D drawn between the player position and that point.

Thanks that worked well.

djmick | 2020-06-20 16:02