How do you make a grappling hook?

After playing the Attack on Titan tribute game, I became interested in the grappling hook, and the way the the physics behind it works. Is there a simple way to make something like a grappling, perhaps in scripting, or through any means possible? I have tried using a spring joint, but I have no idea how I could launch something to grapple out into. Basically, what I intend to do, is create a gameobject the launches out from the grappling hook “gun”, latches on to a collider, and creates a spring joint, other kind of joint, or simple something that would pull you towards it.

In c#, you could ‘shoot’ your grappling hook gameObject by giving it a rigidbody and use this script within Monobehaviour, attached to the hook.

private bool inAir = false;
private HingeJoint grabHinge;
public int speed.

//To shoot your hook, call this method:
void GrapplingShot(){
rigidbody.velocity = new Vector3 (x, y, z) * speed;
inAir = true;
//This is the direction your hook moves multiplied by speed.
}

void OnCollisionEnter (Collision col) {
    if (inAir = true) {
        rigidbody.velocity = 0;
        inAir = false;
        grabHinge = gameObject.AddComponent <HingeJoint>();
        grabHinge.connectedBody = col.rigidbody;
        //This stops the hook once it collides with something, and creates a HingeJoint to the object it collided with.
    }
}

This should get you started. I’m not going to code the whole grappling hook for you.

@Datester35 I think a simple solution its just raycast to where will going your hook. if hits addforce to that vector else do nothing.