I have created a blueprint which can spawn instances of another actor based off of a class template. For example, I spawn a grid of 9 light bulbs in a 3x3 pattern with a separation of 500 units.
By default, every spawned light bulb uses the default properties created in the constructor. IF I use my blueprint class spawner and I create my 9 lightbulb blueprints, and then I want to change the color of those light bulbs before they get placed in the level, is there a way I can expose those lightbulb properties to the blueprint class spawning blueprint? I’d like to not have to do any special coding, so if I want to spawn torches instead of lightbulbs, or spawn any other actor with editable properties, I’d like to be able to expose those editable properties to the parent blueprint which spawns those actors. Is this possible in UE4?
Sorry if I completely misunderstood you but aren’t you looking for the ‘Expose On Spawn’ checkbox in the variable properties? If it is checked along with the ‘Editable’ property it will show up as an input when you use the SpawnActorFromClass node and select that class. Again, sorry if this is not what you looking for.
No, not quite… I know about that meta data property and it doesn’t quite do what I’m hoping for. Here’s kind of the workflow functionality I’m looking for:
Create a new blueprint which derives from the actor class
Add a variable of actor class type (not actor reference!)
Within your construction script, create a for loop which creates 10 instances of this class. We’re NOT looking to spawn these actors, we’re going to be trying to create child components based off of the actor class type we setup in step 2. Within the main body of the for loop, create and add 10 child actor components (And give them a relative position offset).
Now, we’ve got 10 instances of this child actor blueprint in the level. For the sake of example, let’s say they’re light bulbs and we want the color and intensity of the light bulb to be modifiable. By default, the child actor blueprints will fire off the constructor/construction script and use the default values of the light bulb. However, what if we wanted to access and modify the properties of all the child actors all at once? Let’s say my default light color is blue, but I want my 10 lights to have a red color instead. On the light bulb blueprint, I have these variables publicly editable. If I manually place a lightbulb blueprint into the level and then change the color in the editor, it updates the light color via its construction script.
What I’d like to do is select the light bulb class type for the child actor. This would be like creating a rubber stamp. But before I go using this stamp template to spawn a bunch of instanced child actors, I’d like to change the properties of the stamp (such as light color). If I change the light bulb color on the template, it should change the light bulb color on all instanced child actors. This implementation should be generic enough that if I want to change the type of actor I’m spawning, all of the editable properties change. The last thing I’d want to do is manually create “light color” variables in a generic object creator type of class/blueprint because that defeats the purpose of being generic and universally adaptable.
Currently, the only way to do what I’m asking for is to create separate blueprints for each group of objects I’d want to instance and then create and expose custom properties which get applied to every instance.
I was thinking I could create an actor reference to use as my “rubber stamp” template, and make instances based off of it, but I found that the actor references are referenecs to pre-existing actors rather than an instance of an unused actor.
Certainly not a dumb question, I think a lot of people are after what you’re looking for (myself included).
Unfortunately there doesn’t seem to be any native functionality to provide constructor parameters for Child Actor component.
To get around this I implemented a rather convoluted workaround to avoid using child actor components. I created my own Scene Component to handle Spawning and Attaching the would-be child actors to the parent.
The type of actor to spawn and constructor parameters can then be passed in to the Scene Component within the editor.
‘Light’ parent class - has static mesh and a light component, with any variables you want to tweak being applied to the light in the construction script
it has children ‘Light_TikiTorch’, ‘Light_Halogen’ etc, where you swap out the static mesh and maybe things like the IES profile of the point light
then you have ‘LightGridSpawner’ parent class, has all the scripting and variables for creating your child component-based grid of lights inside it - for this it takes a class type variable (purple pin)
then it has children ‘LightGridSpawner_TikiTorch’, ‘LightGridSpawner_Halogen’ etc, in which the only adjustments you make are the above mentioned class type variable