Until very recently, I’ve been making my game in all C++ but I’ve seen many posts advocating against the exclusive use of C++ when programming and instead for a combined approach, blending both blueprints and C++. So, while these questions probably appear super often, I just have a few questions regarding that approach:
Are there any tutorials that use BOTH C++ and Blueprints?
How should the relationship work? When should you use Blueprints and when should you use C++?
Most C++ tutorials I see use blueprints to some extent. For example, Epic’s own C++ tutorials show using C++ to create classes and create the logic while extending those classes to blueprints and using them to modify certain parameters.
The relationship typically involves doing most of the logic in C++ and then extending your classes to blueprints and modifying any exposed parameters. You can have a projectile class which deals with how the projectile travels and what it does when it hits something. But by extending it with blueprints, you can modify how the projectile looks, modify certain exposed parameters such as projectile velocity.
That’s really just scratching the surface on handling C++ and blueprints relationship. There is probably a lot I didn’t cover, but most of what I did cover is how I approach it and is what I have seen others do.
The basic C++ introduction from Epic Games shows you some basic UPROPERTY and UFUNCTION macros. All in all, you will just want to use the macros to expose certain values to your BP Classes.
BPs are Childs. Nothing different than C++ Childs. So you should consider handling them like this. I, for example, have all my Base_Class in C++. Items, Spawner, Containers, etc and even then GamePlay Classes, like PlayerState, Controller etc.
For different Items, i just create new Blueprints. That’s faster than creating C++ Childs and i can directly put Meshs, Animations, Sounds etc and the DefaultValues into the Blueprint Child. It is way faster and easier to have a BP as your last “instance”
of a class. In C++ you would need to load the Mesh and Animation etc through the ObjectFinder. In BP i just need to dragdrop them into the exposed Components and Static Meshs.
Although you can do this in C++ only, it feels more handy this way. You can also put simple logics into the BPs. If you think a specific function should be overridden in the Child, just do it. I mean, BP are slower, but you won’t notice anything
regarding speed when using some BP functions. This is more about complex calculations in comparison with doing them in C++.
Also things like AnimationBP are WAY better to use than creating all of this in the C++ class.
All in all i would say, as soon as the BP gets more handy than the C++ version, use a BP. Need to set default values? StaticMeshComponents? Other BPs you want to spawn? Maybe Widget Class you want to spawn? Create a variable for the ChildBP and just fill them there and use them in your C++ code.