BP can I create a variable(array) that would reference components in same BP

I started with an assumption that I should be able to create a variable of type actor component or static mesh component, and populate it from the drop down menue to point at some components

example. you create a clown actor, the clown has 12 ball components “static mesh” or “static mesh component”. You want each ball, in order to change colors. you want to put reference to the balls in order in a array to help make this happen.

I create an variable of type whatever (I’ve tried many to see if I can get it to work) but in the end it’s not a type mismatch because I can manual add the components with an add node to the array.
I compile the BP and drop down the array elements but it’s always empty.
I’ve tried soft refs,
I’ve tried instance editable and tried to populate the the world outliner details, still empty.

I’ve tried “get components by tags” but they don’t come in order ( ordering the array is off topic here)
and I’ve strung together 12 “add” nodes to get what I want, it’s big and messy.

I was hoping someone might know If it can be done as I assumed? I mean you can build it manually, why not be able to use the drop down menu? Is there a better way I don’t yet know about?

Thank you for any suggestions.

Sorry your question was a little confusing, hope I understood it correctly. Also, this method is bad because it uses a lot of memory, but it was the only way I could think of.

First, make sure all of your components are “child actors” of a base actor. For example, I have a bunch of guns that are all child actors from “Base Gun” actor.

Then create a variable array of “Base Gun”

Then use the “make array” node and order them like you want

You can add the actor/staticmesh components to an array but you will only be able to fill the array at runtime so you wont be able to see them in the drop down. Even at runtime the array drop down wont fill, that does not mean the array is empty though.

You need to remember that the array and the components don’t actually exist until runtime (game starts). This is why you can’t fill the array with defaults of object references. Objects don’t exist until the game starts and they are created.

You can definitely add them to the array in a correct order though using the add node in begin play. The first one you add will be the last one in the array though.

A screen shot of your bp would also be helpful.

That will not work. Those are classes not object references. You can’t reference an object that does not exist and objects don’t exist until runtime.

Wow, I wake up and find it’s Christmas morning. Thank for the replies, it helps me a lot to understand why it’s not populated, may take some time to wrap my head around it.

“Make array” is a step up from my string of 12 “adds”.

was going to add a screenshot, forgot to click save. It’s there now.

Thank you all

Oh my god, of course. I forgot “make array” exists.
Still its frustrating if you have to work with 25 components like me.