Hello! I’m completely new to UE4.
I’ve discovered how powerful is the Blueprints Visual Scripting, but I have the feeling that when the control became really strict to the developer, it’s hard to achieve that with Blueprints, so I need the programming approach.
One simple example: let’s suppose I want to make a simple running ball game with procedural content generation. With blueprint I can manage events like collision, but what about the procedural content generation? I can easily create an custom algorithm on my own, but to do the same in Blueprints setting all nodes will be hard.
So my question is: is it possible to use both in a project? Is it a good idea to use Blueprints wheter it’s easy and using c++ algorithms for example AI part of the project?
Enabling С++ do not prevent you from using blueprint at all. All blueprint features will still working in cpp project
Yes, you can use Blueprints and C++ together. In C++ you’ll use UFUNCTION() to define whether or not blueprints can access it, what it can do with it and what it requires to operate. I don’t think it’s bad to use blueprints - when packaging most of this should be optimized to C++ and then compiled anyway, and C++ is also a very powerful tool to have available.
You can definitely do a lot of AI related shenanigans from C++, we’re doing that atm with a bachelor thesis.Part of our project involves exposing the work we’re doing to blueprints as well to create a user-friendly experience. ![]()
Yes it is possible. I’ve done it already. Here are things that you have to keep in mind, tho :
- They cannot always communicate directly, as BP is not C++ until you compile them. BP can communicate with C++, but the other way around is more complicated.
- Get ready for a shitstorm of casts and UFUNCTION(), get ready to have a millions functions if you are doing your own pawn with replication capability.
- I strongly advise you use C++ to make your base classes, especially abstract classes, and then right click and your class > make BP from class to create a BP in which you will easily put a mesh, etc, using the viewport. This is way easier than guessing the position of every component with C++ functions.
All in all, everything that is abstract is better done in C++, at least because you don’t need 15m² of space just to make a simple formula. The rest can be done in BP. To communicate, the best way IMO is to have a C++ class for every BP so you can simply cast your BP to it and use every functions in the C++ class.
EDIT : Let me give you an example of what I had to do. So I had a building (HQ_BP) that the player could build. The base C++ class was abstract (HQ), and was derivated into a HQ_BP class so that I could move my components using the viewport. Every functions I needed were in the C++, so that the BP was purely cosmetic. When I had to deal with the HQ in my C++ were all my logic was, I could simply cast the HQ_BP to the HQ and use every functions I needed. To create an instance of my HQ_BP from C++, I used a ConstrutorHelper to find my BP file (I don’t think this is the best way, but that works).
Now, If you were to try it the otherway around, that is, doing a BP with a lot of functions and try to call them from a C++ file, I think you’ll gonna have a bad time. This is what I mean by “uncompiled C++”. Maybe things have change since, but I’m not sure about that.
What do you mean BP to C++ is more complicated? I honestly haven’t noticed a difference between BP to C++ function and BP to BP function.
Yeah mistake, it’s C++ to BP which is more complicated, because BP is uncompiled C++, so you have to use ConstructionHelper or use some parameters for your variable (like BlueprintEditable or I don’t remember which).
But isn’t there like a bake BP function ? Maybe it’s easier if we can do that. Honestly, I’m clueless on that. I just remember that doing C++ was very cumbersome when having to deal with BP. I followed some advice and did what I told him to do : Make a C++ class with all the functions you need + components and then make a child BP of that class to arange your components. From there is it possible to use every C++ functions.
Honestly not sure I follow your sequence of actions, but I’ll take your word for it. I’ve only played around with using C++ functions in Blueprints, implementing C++ functions in Blueprints and that kinda stuff. Never the other way.