Say I have instantiated an object:
GameObject example = Instantiate();
I change the parent of said instance to the GameObject attached to this script:
example.transform.SetParent(transform);
I would expect that, since the instantiated object is in the hierarchy of the GameObject attached to this script, that the following code would not return an empty list:
var bodies = GetComponent();
However, it does. I know that the prefab in my code has a Rigidbody component. Since the instantiated object is in the new hierarchy, and the Rigidbody is a component of that instantiated object, why is it not returned by GetComponent ?
Thank you in advance for anyone’s advice.