The function I'm currently working on instantiates a GameObject (using a prefab). I store this GameObject in a local variable
GameObject tmpObject;
Works flawlessly. Next I try to assign this GameObject to my GameObject representation of my Vive controller, which looks like this:
tmpObject = tmpController.gameObject.AddComponent<GameObject>() as GameObject;
The error that I get is that UnityEngine.GameObject cannot be converted to UnityEngine.Component.
Am I missing a simple / basic there? I tried adding a SphereCollider as per Unity's official guidline and it did work, so why can't I add GameObject? Is there a workaround to adding GameObjects to another GameObject? Any help is greatly appreciated!
GameObject
could have properies/components, however aGameObject
can't contain otherGameObject
s. Its a different story if you want to assign aparent
as aGameObject
to another. – Conduplicate