- Home /
how to make prefab clone as a child of prefab clone?
Okay I have browsed half of the internet trying to solve this simply issue. Im trying to make already cloned prefab instantiate another prefab clone and the instantiated clone as a child of the clone that instantiated it.
var lazor : Transform;
...
if(Input.GetAxis("shoot")){
object = Instantiate(lazor, transform.position, Quaternion.Euler(0, 0, 180));
object.parent = transform;
...
}
This code was in a prefab. When I instantiate the object, everything is ok, but when I add the line "object.parent = transform" it disappears even from the hierarchy. (it doesn't even appear in hierarchy but appears then when I use yield WaitForSeconds.)
Tell me if you need more explanation. Thanks!
This may not work but try the word var in front of object = instantiate.... It may work :)
Here keep in $$anonymous$$d that it only disappears when I try to set the parent. otherwise it just instantiates it.
oh and there's one block that destroys everything that hits it, but it wasn't the causer because I tested it with debug.logs
Your answer
Follow this Question
Related Questions
Make a simple tree 1 Answer
Separate different kind of prefab/enemy ? 0 Answers
How can I access the 2nd tier of children on a prefab in the Project Folder Window? 4 Answers
Putting a variable of a child in the inspector for the parent 1 Answer
How to Instantiate Prefab as Child of Player OnTriggerEnter 0 Answers