0

I have a moving object containing some objects.

When i'm creating some of the child objects and setting the parent to parent object, the created object does not move with parent.

I checked the hierarchy panel. but the created objects are not in the parents as a child.

this is my code:

GameObject parent = GameObject.Find ("Ground");
clone.transform.parent = parent.transform;

What is the problem?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Person
  • 345
  • 2
  • 4
  • 11
  • code looks fine, but does the code actually run? – CodeSmile Nov 12 '14 at 17:54
  • Yes it runs. because when i'm debugging, it prints Objects name. – Person Nov 13 '14 at 05:24
  • not sure if it's involved in the problem but transform.parent is a "Transform" data type according to the documentation, not a GameObject data type; so it's having to convert that behind the scenes. – Lefty Nov 13 '14 at 13:58
  • Code is just fine and working. Please recheck if GameObject.Find is giving you the proper object by Logs or Break Points. – Hamza Hasan Nov 14 '14 at 07:09

0 Answers0