Getting an array of all components of a certain type in blueprint
I have a blueprint that has a number of components of the same type attached to it. I would like to be able to iterate through them, is this possible? At the moment, I am manually dragging a node on for each one and combining into an array. Is there a more robust way to do this?
asked Jun 12 '14 at 08:15 AM in Blueprint Scripting
As discussed in the comments, there is no function which achieves this for blueprint but it can be easily added to code. I wrote the following method to extend the Actor class to allow for this functionality. When I get a minute to tidy it up, I will make a pull request on Github, until such a time here is the function I am using:
The main limitation this has is, in bluprint, you must loop through the returned array and cast it to the actual component type you need.
Like I said, when I get some time, I'll investigate into whether it is possible to have generic blueprint functions so the function could actually return the correct type.
I have created a pull request, you can see it here:
there's definitely a way to do that in C++, probably with the degree of control that you're after. I've never used it, but have you looked at GetActorListFromComponentList node? It takes an array of components and outputs an array of actors, and it has a class filter. You could maybe filter for static mesh or whatever it is that you want to isolate and then cast from actor class on the other side of the array that it makes?
answered Jun 12 '14 at 09:11 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here