The question is answered, right answer was accepted
Instantiating as a child of an object in hierarchy
Hello!I have a problem with instantiating things as childs.Yes,I googled my problem but everywhere i found something like transform.parent = instantiatedObj.This way the transform will be realtive to parent.But in my project(FPS) I instantiate a BulletHole at the hit position of a shooting raycast on an entity that soon will be destroyed so when it gets destroyed bulletholes are still there,in air,so thats why i need them to be a child of that entity so that when i delete entity the childs(BulletHoles) are destroyed too.I see the way too instantiate them as a child of the hit object but if there any other ways to do that please tell me.
Have you tried setting them as children through transform.parent and then changing their position using transform.localPosition?
Answer by Jordi-Bonastre · Feb 26, 2016 at 04:53 PM
You could destroy all the children using the function OnDestroy: http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDestroy.html and continue using the previous option "transform.parent = instantiatedObj"