UChildActorComponent in array

Hi all ! can anyone explain why I can’t set the UChildActorComponent in blueprint created from c++ class while it is in array ?
I have a c++ class and I’ve created blueprint from it in this class I have array of UChildActorComponent* in constructor I create UChildActorComponents in array they are shown in blueprint but I can’t assign the actor to them, just to test I’ve set up a test UChildActorComponent* as a single instance and it works

here some pictures

Hey Mlody-

Attempting to create an array of components is not a supported workflow. When you create the array the editor sees that you are attempting to create a component and will generate it as a component, but because it is an array it is being treated as a variable which causes the editor not to know what to do with it. Rather than creating an array of components, it may be better to create a single component and set its value in the blueprint as needed.

Cheers

Thank’s for the reply, the thing is that I will have more blueprints of weapon type so I would have to create multiple pointers, is it possible to load the blueprints programmatically ? I don’t mind not being able to set this in editor if I run the code from compiler I can see the components are created so if there is a way to possibly create all my weapon blueprints in separated folder and load them from there in the loop than I can go with that

Right I’m stuck at debugging I’ve managed to modify my code a bit so now instead of modifying the components in editor I have set an array of TSubclassOf WeaponType> and in editor I set the values to my weapon blueprints than i BeginPlay I set the ChildActorClass on each component everything works great except the fact that as soon as the code exits the BeginPlay the ChildActorClass gets nulled on each component and I can’t find the reason why

You should be able to use the Set Child Actor Class node to specify which of your weapon blueprints to assign to the pointer as necessary. With the code based child actor component, I was able to setup a quick test that swaps the child actor from a cube to a staircase when a key is pressed/released. You can use this same logic to assign a specific weapon to your child actor component and then switch to another weapon by replacing the original (somewhat like a weapon swap).

96282-childactorcomponent.png

Hey Sorry for the late response, I can see your point now, I’ve must misunderstood the way this components should be used, I think I will have to redesign my objects hierarchy, I’m using child actor component as I need something that can spawn other objects, render, and can be attached, but I think I’m just gonna use scene components instead and access the owner actor by the GetOwner() method