HI !
I try to add custom component to a new child gameobject. Here’s my code :
private void Initialize(MvtCube Parent)
{
duplicate = Parent.duplicate;
TimeSpeed = Parent.TimeSpeed;
f = Parent.f;
A = Parent.A;
nbHarmonique = Parent.nbHarmonique;
trail = Parent.trail;
mesh = Parent.mesh;
filter = Parent.filter;
duplicate += 2;
}
private void Start()
{
if (duplicate <= nbHarmonique)
{
new GameObject("Cube" + duplicate).AddComponent<MvtCube>().Initialize(this);
}
}
I Just would like to add the component trailRenderer(for exemple) from the parent to the created child.
I’m still new to unity and to this community. I hope i asked my question correctly.
Thanks A lot !!