Question for few things about C++

Hello!
From few months I am struggling with a lot arrays and a lot actors references and it takes too much time to even connect one array with references (over 100 meshes for example) which then leads to gigantic spaghetti monsters (which is not exactly problem). I want to learn to use basic C++ like a macro to “automatize” the manual connecting between nodes (exec pins, ref pins etc etc.)

So the scenario is I have one bp actor which have 50 components (static meshes) and I want them inside an array, yes I know that there are nodes that do this but just for the sake of my question lets ignore them and I have good points on that they make things more complicated but anyway.
Is it possible to theoretically access the components from the bp actor from the Visual studio app, and then just write few lines to put them inside an array and then compile it so that the nodes will come out automatically inside the bp actor?

Thanks in advance! :slight_smile:

You need to declare all of these static mesh components inside your c++ class instead of the BP class.
You can then create an array of the static meshes, and put them all in on construct or begin play.
Easily done with a bit of copy paste and some name changes.

Sorry for the late answer the last few days were very busy for me. Thank you for the answer, I will take a look on this. But is it possible to connect execution and other pins in C++ so that they show up connected inside the blueprints?

You want yo use C++ to build a blueprint graph? That sounds possible, but very cumbersome. There are much easier ways to get your components in an array using only blueprints without need for manually connecting each one of them by using either GetComponentsByClass or GetComponentsByTag nodes.

If you need a list of all StaticMeshComponents, call GetComponentsByClass. If you need only some of them, add component tags to them and use GetComponentsByTag to get a list of StaticMeshComponents that contain that tag.

When you are in C++ you can specify a function call as BlueprintCallable using the UE4 Macro. Example - UFUNCTION(BlueprintCallable). With that you will be able to call the function from a blueprint. There are other key words to give you more functionality. I would suggest reading some of the documentation on UFUNCTION. There are also some good tutorials on writing some code in C++ then using them in blueprints. I would checkout Unreal on youtube, some of the stuff is a little dated for C++ but still works just the same when working with both blueprints and C++.

I may have misunderstood. If you are thinking that you can take a blueprint to C++ and show that things are calling the proper functions, you may want to read the documentation or How to convert a BP/Content to C++ maybe helpfull

Yep, I know about those nodes its just the flexibility Blueprints <> C++ I want to learn to use so that when out of the box ideas comes I can have 100% flexibility to make them work fast for testing. :wink:

Thanks for the keywords and the links, I needed to know where to begin learning c++ for UE4. :slight_smile:

You are welcome. I am only a few weeks into C++ in UE4 and the documentations has helped a lot. There are tutorials out there that will help some as well. I am a computer programmer so programming is somewhat easy to me but C++ in UE4 is a bit different and takes some getting used to. Good luck with your projects!

Thanks! :slight_smile: