Download

How exactly should I use C++?

I’m starting to learn the Unreal Engine using C++ and I’ve often been wondering to myself about how exactly I should be using C++ in Unreal.

It’s kinda hard to explain but I think it’s likely due to a lack of understanding about both blueprints and C++ within Unreal. I come from a Unity background so what I’m used to doing is essentially programming components and attached them to prefabs which I’m pretty sure you can do in Unreal, where you attach custom components to blueprints. But then you have stuff like the ability to actually program the blueprints themselves which sort of confuses me a little and makes me wonder stuff such as should I be programming all my functionality of the player, enemies and such within classes that the blueprints inherits from or do something similar to what I’ll do in Unity where I’ll make multiple different components for moving, firing and then attach them to the prefab/blueprint?

I feel like I should be going with the latter as it’s what I’ve seen most tutorials on programming with C++ in Unreal do but I feel doing it that way would remove some flexibility. Like what if I had multiple blueprints for multiple different types of enemies, with each enemy having some slight differences in functionality to each other. I surely wouldn’t have to create multiple classes for each of these blueprints to inherit from would I? Or would I then go for the Component route where I create different components and attach them to their respective blueprints?

Hi there. Let me try to put to you something:

  • Unreal allows you to code everything in C++ for your entire game. It is where you would be able to extract the most juice from the engine;
  • There are things that are easily done in blueprints because the visual appeal are easy to figure what is being done and also, it is even more appealing for non-coders, since many users are just artists;
  • plugins usually expose functionality to blueprints or implement their own set of blueprints, meaning an artist can use what you develop and ofc not needing to rely on knowing how to code;
  • writing plugins or developing specialized code demands study of the api deeply, because writing bad code is more easy than you think. Thats true for C# or C++ no matter which engine we are talking about. There are plugins that implement just global functions, others implement new types (structs, enums, classes), others implement new menu items, new editor functionality, and the list goes far;

My suggestion on the study:

  • dirt your hands the most of you can with blueprints. The more you understand the limitations, the better. Things like animation are much easier handled in blueprint;
  • once you achieve good understanding, you try install a free plugin available around, try to understand what was introduced in terms of functionality and how it is used in blueprints;
  • once you understand the above, you can start studying the code of that C++ plugin and learn. Start from the simple ones otherwise it will be too overwhelming;
  • always try to understand the relationship of all Unreal modules and classes, and mainly understand what is the functionality already built, so you will not reimplement features already done;
    It is time consuming, it is not something you will learn in few months, you might want to focus on something first. The more generalist you think, the more time it will take to understand everything.

Good luck!

Short answer, go for a C++ Component based design. Expose the Components API with Blueprint events, put the top game logic in Blueprint.