2D GRAPPLE GUN QUEST: ‘Keep on Swingin’ - Solutions

Quest: 2D Grapple Gun Quest
Challenge: Keep on Swingin’

Feel free to share your solutions, ideas and creations below. If you get stuck, you can find some ideas here for completing this challenge.

    private void PullPlayer()
    {
        joint.distance -= grappleSpeed;

        if (hit)
        {
            if (Vector2.Distance(transform.position, hit.point) <= 0.1f)
            {
                joint.enabled = false;
                line.enabled = false;
            }
        }
    }
private void MouseHeldDown()
    {
        if (Input.GetMouseButton(0))
        {
            PullPlayer();
            line.SetPosition(0, playerHand.transform.position);
            if (joint.distance < distBetweenPlayerAndPoint)
            {
                ReleasePlayer(false);
            }
        }
    }
private void ReleasePlayer(bool enabled)
    {
        joint.enabled = enabled;
        line.enabled = enabled;
    }
1 Like