move gameobject in unity to another object code example
Example 1: how to move a gameobject to another object
public GameObject Bullet
public GameObject Cannon
void Start()
{
(Bullet) = GameObject.Find("Bullet");
(Cannon) = GameObject.Find("Cannon");
Bullet.transform.position = Cannon.transform.position;
}
Example 2: unity how to move an object to another object
transform.position = new Vector3(GameObject.Find("Object").transform.position.x, GameObject.Find("Object").transform.position.y, GameObject.Find("Object").transform.position.z);
transform.position = new Vector2(GameObject.Find("Object").transform.position.x, GameObject.Find("Object").transform.position.y);