How to get a Distance Joint 2D to connect to my player GameObject?

I have my player fire a projectile, and where it hits terrain it creates my gameObject HookPoint. How do I get my HookPoint to have its Distance Joint 2D to be Connected to the player, which is already in the scene?

What you’d want to do is change "̶a̶t̶t̶a̶c̶h̶e̶d̶R̶i̶g̶i̶d̶b̶o̶d̶y̶"̶ “connectedBody” on the Joint2D component to your players rigidBody2D component. How you do that will depend on how your scene Is set up, but a script like this on the HookPoint Object might work:

using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class HookPoint: MonoBehaviour
 {
	 // Awake will be called when the object is instantiated
	 public void Awake()
	 {
		 Joint2D joint = GetComponent<Joint2D>();
		 GameObject player = GameObject.FindGameObjectWithTag("Player");
		 joint.connectedBody = player.GetComponent<Rigidbody2D>();
	 }
 }

Worth noting this method requires the player to be tagged as “Player” in the inspector:

alt text