Grapple Gun?

I’ve been looking for a script to create a grappling hook on the internet but all of the codes seem a little too complicated. What i want to do is to be able to only click on certain gameobjects that allow the grappling hooks to attatch onto and retract the player to that position. I’m pretty sure I have to use a raycast to see where the grapple hook has to go, and also a line renderer to create the rope for the grapple hook. But i’m really not sure about how to combine these and how to retract the player to the position. I’m a bit of a noob to coding so some description of the code would be really helpful as well.

Thanks In advance

Although I’m not exactly sure how to do it, I’d imagine it’d have to do with Vector3.MoveTowards().
You could do the following:

  1. Raycast when the mouse is clicked (or however you do it)
  2. Get the gameObject’s tag from the raycast.hit information
  3. if the tag is an allowed surface to grapple onto, use Vector3.MoveTowards(transform.position, RaycastHit.transform.position);