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;
            }
        }
    }
1 Like
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

My solution, basically continuing off from the second challenge:
1st

Made a separate method to show disabling/enabling the line
2nd

Privacy & Terms