- Home /
How to change part of complex gameobject instantiated from prefab?
I have 2d car complex prefab with all colliders and sprites setted, instantiate object from it and I need to change some child element in the runtime by script (e.g. destroy/change posion of wheel) without losing intergrity. How it can be done?
I don't need fixed changes, they must be caused by script.
Answer by A3tra3rpi · Dec 17, 2014 at 01:14 PM
Something like this?
GameObject TMP = Instantiate(prefab,transform.position,transform.rotation) as GameObject; TMP.transform.FindChild("Part1").position = new vector2(0,0); Destroy(TMP.transform.FindChild("Part2").gameObject);
This works for me in 3D
Your answer
Follow this Question
Related Questions
Modifying several gameobjects with an editor script? 2 Answers
Changing gameobject assigned to a variable from string 1 Answer
script help gameobject to playercar 1 Answer
Changing or replace objects 2 Answers
Drag object 1 Answer