Procedurally generated components randomly reattaching after BeginPlay()

Hello,

I’m having an odd Issue with procedurally generated components(see also this): when i press play in the editor, the attachments get rearranged randomly, resulting in odd behaviour. once every few plays however it just works fine.

Help is, as always, appreciated.

What do you mean the attachments get rearranged? Like they are attaching to different things than the thing you are trying to attach it to?

Could you copy your attaching code with renamed variables/classes if you can’t share it and then say what your expected result and actual results are?

Yes. I havn’t checked wether some child components disappear, but there are definitely some components that don’t have any children anymore at all(They should all have 6) and there are some, that have children of another parent component. After creation in the editor everything is fine, but as soon as i press play they go crazy

This is my attachment code:

 tmpComponent = NewObject<UCV_CubeComponent>(this);
 tmpComponent->AttachTo(RootComponent);
 tmpComponent->RegisterComponent();

Note that these components are NOT UProperty components. They are procedurally generated and referenced in an array. I don’t really think that this should be a problem.

Solved it.

I had not given my components unique names. i gues it might have mesed with serialization somehow.

SOLUTION: Always give your components unique names.