[4.7.6] How to set/change child actor's class?

Hi there,

I’m trying to build a system where you could change the specific class to use for the light of a car in the editor:


All these classes are derived from the same base class BP_light.

That means, if the level designer chooses another class, I have to destroy the currently used lights and spawn new ones of the selected class instead. Unfortunately it’s forbidden to spawn new actors in the construction script for some reason:


So I tried to implement this with child actors instead. But it also seems impossible to change the specified class for a child actor in the contruction script (there is simply no setter node for the class to use for the child actor):


Next, I tried to destroy the child actor and add a new one with “Add child actor component”, but you can’t set the class to use there either!


Instead, the description says something about a ‘template name’ which could be ‘found in the owning blueprint’. But I can’t find this setting also.

So here’s my question: How can I replace an (child) actor of a blueprint in the construction script with an instance of another class?

I know it’s no problem on runtime with ‘Begin Play’ but I want to configure this parts directly in the editor instead of starting a game each time to see the result…

Is this currently even possible?

Many thanks,

Hey , any luck with this? I’m actually trying to sort out the same issue.

I’ve got a weapon attached to MyCharacter BP as a child actor component and wondering if I can swap out the Child Actor Class on the fly.

I’m beginning to think I may have to work this swap functionality into the weapon’s BP…

Hi SVR33,

no, unfortunately, there seems to be no solution for that. UE4 is really inflexible if terms of composing when not using C++. It’s really a pain in the neck. I made dozents of workarounds for this to preconfigure child actors.

You can only vote for this trelly card here:

(A few days ago this was named ‘preFabs’ and had about 450 votes)

You can set the class, just get the component and set child actor class.

47425-setchildactorclass.png

And the component template issue is a weird. It only shows up when you add child actor component while pulling off of a mesh. So my assumption is that it’s already done for you it just doesn’t say it.

Then again I was reading this, link text, and Steve from EPIC says a child components class can’t be changed at runtime.

you also can’t change a child actor component’s class at runtime

Hmm, that’s indeed a pretty clear statement.

But indeed, there is a setter node now. I could swear that this wasn’t there in 4.7.6. I will try this out as soon as I can.

EDIT: It works definitly from the construction script and ingame, too! :slight_smile:


http://syh.sweetwaterschools.org/files/2014/05/Cheer.jpg

That’s awesome, good luck with it.