How to make a Game Object Become another Game Object's Child Object.

Hello, I am trying to make a game where the player is within an empty game object and enemies comes in from the Z axis. Once the enemy comes in within the threshold I’ve made a variable of, I need to make it so the enemy becomes a part of the same game object as the player. I am doing it this way because the game is a forward scrolling 3rd person shoot em up and I feel but not doing this way would make it much more difficult for me to solve my problem.

So in all is there a way to make a game object a child of another game object? I would really like some advises and help from others and hear what they think. Thanks in advance.

Here is the code I’ve been working on for awhile:

using UnityEngine;
using System.Collections;

public class EnemyAIMelee : MonoBehaviour 
{
	public float targetDistance = 20.0f;
	public float enemySpeed = -50.0f;
	
	// Update is called once per frame
	void LateUpdate () 
	{
		GameObject plane = GameObject.FindGameObjectWithTag("PlayerPlane");
		if (transform.position.z - plane.transform.position.z <= targetDistance) 
		{
			//Make Gameobject a child of PlayerPlane?
		}

		else
		{
			transform.position += transform.forward*enemySpeed*Time.deltaTime;
			SendMessage("EnemyMovingAnimation", true);
		}
	}
}

trasform.parent = plane.transform;

the hierarchy is built with transforms, not with GameObjects :wink: