2D: Pass projectile between two objects on fire command

Hello. I have some trouble finding the right code for my problem:

Let’s say I have two objects [Player 1 and 2] facing each other. Player 1 [P1] has a projectile [Ball]. On fire command, Player 1 shoots the ball in the direction facing.

Here is the part that I am missing on what code to use: I’d like that Player 2 grabs the ball on collision.
Question: What script do I have to write so that Player 2 grabs the ball/is attached to Player 2?

Once this is figured out. I’d like that Player 2 shoots the ball back into the direction it is facing. In the end, the ball can be shot back and fourth between the two Players. It is analog to passing a ball for a soccer game, but resources there did not help.

(I can script how to shoot in the direction faced, but really have no clue what to use to grab/attach the ball to the other player).

Any suggestions? Thank you very much!

To attach one GameObject to another, you can set its transform.parent to another GameObject’s transform. So it’d be something like ball.transform.parent = Player2.transform, or if it’s a human character, maybe something like ball.transform.parent = Player2.HandBone.transform.parent (or the hand could be down in a much deeper hierarchy, depending on how your character is set up).