We have a system in an existing project that previously would add and configure child actors inside of the construction script. Since updating to 5.6, that functionality appears to be broken. Properties that were previously cached off to the child actors during the parent’s construction script don’t appear to persist when starting a play in editor session.
I was able to reproduce similar behavior in the First Person starter project, so I’m doubtful that there’s anything project-specific that is causing this bug. I can provide repro steps if needed.
Having the same problem, trying to find a work around. Hope they address this, all previous versions have had no problem spawning child actor components in a constructor.
Alright I came up with a solution. Depending on how much and what kind of data you need to pass to the child actor components you are spawning in the constructor, it may or may not work for you.
Basically the problem is that any data you try to associate with the child actor component when you spawn it in a constructor is dissociated when you begin a play session. All of the data EXCEPT the transform. If the data you need to give the child actor component is either related to the transform you assign it OR you can somehow encode the data you need to pass into the child actor’s transform, then you can technically pass the data to your child actor’s via their own constructor. (I’m not sure what kind of data you need to pass, so I don’t know if encoding it into the transform is possible in your case).
Constructor I’m spawning child actor components in (Before changes)
Once you have your data encoded into the transform, you can pass that data into the constructor of whichever actor you are spawning as a child actor component. For example, in my case I’m spawning cells in a grid that need to know what their coordinates are. So I calculate their transform in the Grid’s constructor, pass that transform to the child actor component (which persists after begin play), and then use that transform to calculate the cell’s coordinates inside the cell class’s constructor. I also get a copy of the grid inside the cell’s constructor and modify some of the grid’s data. Between the transform workaround and being able to access the parent object inside the child object’s constructor, I was able to work around this problem.
As you can see, I’ve basically migrated the data assignment to the child actor component to its own constructor and removed it from the parent constructor. Using the transform supplied in the parent constructor, I’m able to pass enough contextual data to assign my cell classes a coordinate value by doing some vector math.
Anyway this worked for me. My project doesn’t have any errors or warnings and seems to be in an identical state to what it was in previous UE versions. Hopefully you found this helpful and can try something similar