Hi Adam,
The Child Actor Component controls the lifetime of the Child Actor: it spawns the child actor when it is registered and destroys it when unregistered. This is why you cannot change the “Child Actor” property directly. On the other hand, once you set the “Child Actor Class”, the component creates an internal actor called “Child Actor Template”, which is used to initialize the actual child actor once it is spawned. You should be able to change properties on that template to achieve what you need, but you will need to use C++ to implement and expose to Python some helper functions:
`UCLASS()
class UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintPure)
static AActor* GetChildActorTemplate(UChildActorComponent* ChildActorComponent)
{
return ChildActorComponent->GetSpawnableChildActorTemplate();
}
UFUNCTION(BlueprintPure)
static UActorComponent* GetComponentByClass(AActor* Actor, TSubclassOf ComponentClass)
{
return Actor->GetComponentByClass(ComponentClass);
}
};`With this in place, you can something like the following in Python:
`child_actor_component.set_child_actor_class(unreal.PointLight)
child_actor_template = unreal.MyBlueprintFunctionLibrary.get_child_actor_template(child_actor_component)
child_actor_template = unreal.PointLight.cast(child_actor_template)
point_light_component = unreal.MyBlueprintFunctionLibrary.get_component_by_class(child_actor_template, unreal.PointLightComponent)
point_light_component = unreal.PointLightComponent.cast(point_light_component)
point_light_component.set_light_color(unreal.LinearColor(1,0,0,1))`Note that you might run into some difficulties along the way because of how the Child Actor Component works (configuring a non-spawned template actor, then spawning and despawning the actual actor when registered and unregistered, which happens more often than you’d think). For example, when testing the solution I just presented, I had initially used “point_light_component = child_actor_template.get_component_by_class(unreal.PointLightComponent)”, but for some reason I could not get this to work, and was able to work around it by creating my own wrapper GetComponentByClass() function in C++.
As for alternative solutions, it could be helpful to learn more about the reason behind what you are trying to achieve, but in any case here are some thoughts:
- Follow your first approach whenever possible, for example by creating PointLightComponents in the target actor directly to replace PointLightActors
- Simply attach your “child blueprint” to the target blueprint, instead of using a child actor component, if this is enough for your needs
- Use instanced levels: maybe you could keep the user scene/level untouched and use a Level Instance Actor to instantiate it inside another level, if that resonates with your end goal
Please let me know if this is helpful and if you have any further questions.
Best regards,
Vitor