Make instantiated prefabs the children of another gameObject

Hi guys,

I’ve seen a few similar questions to this around here but none of them solved my problem. I’m instantiating a series of items that I’d like to attach as children to another game object. The purpose of this is to affect the rotation of the parent object’s transform.

GameObject parentObj = Instantiate(items, new Vector3 (spawnPos.x + i*dist, spawnPos.y + j*dist, spawnPos.z + k*dist), Quaternion.identity) as GameObject;

parentObj.transform.Rotate(Vector3.right * Time.deltaTime);

However, I’m getting an error saying parentObj onflicts with a declaration in a child block.

Is anyone able to point out what I’m doing wrong? It would be really appreciated.

Thanks.

It means you have parentObj declared twice in your method. Probably once at the method level and again within the body of an if or other sub-block.

Id need to see the entire method to tell you exactly where the conflict is.