I know this is the simplest of tasks. But I’m really confused here. I’m instantiating the object and trying to assign its parent as self (the empty gameobject script is written onto). Tried the following:
var robot = Instantiate(robots[0]) as GameObject;
robot.transform.parent = transform;
it didn’t work so I tried:
public Transform self;
var robot = Instantiate(robots[0]) as GameObject;
robot.transform.parent = self.transform;
This didn’t work either. I tried assigning self to another gameobject too. GameObject is instantiated as expected but parentless. Console is throwing “Null Object Reference” error. I’m really frustrated over here. Please help.