- Home /
Child objects material is changed from parent
in runtime i am instatiating a prefab and making it as child of laser beam in VR app as below,
prefabobject.transform.parent = laserbeam.transform;
now when it is attached to laserbeam, Prefab's materials are overridden and set to same as laser beam, how can i avoid this, it looks ugly , can anyone please suggest me how to avoid/change back again.
This is how it looks,
Original Prefab
When it is instantiated and attached as child via script using above piece of code (i am not doing anything extra other than that line), you guys see a green line it is laser beam emitting from hand controller. Regards, Jung Lee.
I didnt get the solution for above explained problem, but i chose awork around for this and working fine, what i did is ins$$anonymous$$d of making prefab as child to Laserbeam, i am just independently updating the positions of prefab based on laserbeam which is working as expected.
Your answer
![](https://koobas.hobune.stream/wayback/20220612120417im_/https://answers.unity.com/themes/thub/images/avi.jpg)