How To Get Cloned Object Information

hello unity community

i Instantiated gameobject but i can’t get any value of it . its weird because when i try to set value its work perfect but when i want to get a value its not.

 var newNode = (NodeG)Instantiate(node, RHit.point, default,target.GetChild(0)).transform.GetComponent<NodeG>();

        print(newNode.name); // Node(Clone)
        print(newNode.pos); // 0,0,0

A game object isnt your monobehaviour it has them. Unity uses composition.

Assuming node is an Object: Try:

var newGameObject = (GameObject)Instantiate(node, RHit.point, default,target.GetChild(0));

var newNode = newGameObject.GetComponent<NodeG>();
 
print(newNode.name); // Node(Clone)
print(newNode.pos); // 0,0,0