Create a Blueprint class using a C++ class as parent class: why is this useful?

I’ve just started to learn developing game using Unreal Engine 4.26.2.

I’ve been reading a lot of tutorials from Unreal and courses from Udemy and, in most of them, they create a BP class using a C++ as its parent and I don’t understand why. They do it as these are the steps we have to do every time when we want to use a C++ class in Unreal Editor. But I don’t do that and I can work fine with the C++ classes in the Editor.

Why creating a BP class using a C++ class is useful? Or, why they do it with every C++ class?

He look more professional :sunglasses:
All my base class are blueprints and everything is correct.
Base class c ++, interfaces, event drive, tick is a satan, and use lot or functions if you don’t put that in your tutorial no one takes you seriously.
But you don’t need any of that actually, a good spagetti blueprints is enough for most of your first games and prototypes.

C++ is more efficient
Here is a video showing difference in performance : UE4 Performance - BP vs C++ vs Blueprint Nativization | feat. Multithreaded Tick - YouTube

You don’t necessarily have to add code to blueprints.
You can use them like Unity prefabs, to prototype classes within the editor, where they only store default values.

C++ is more efficient than Blueprint, and I think if I create a Blueprint class using a C++ as its parent it is slower than if I use the C++ directly, is that correct?

No, blueprints will not convert everything to blueprint functions.

The only blueprint functions that are slower are the function graphs that you create with nodes.

You can create blueprint events that call blueprint functions that are nothing more than simple wrappers to the C++ code, function libraries built from C++ are very useful because of that. It’s very different from functions built 100% with graphs and nodes.

1 Like

OK. So, why they do create a BP class with every C++ class?

Does it look more professional?

1 Like

People do it because they usually want to build easily configurable classes.

If you don’t like it, you can create a

UCLASS(Placeable)

And do everything from native code, but the more your project grows the less productive you will become and the more problems with construction helpers you will face.

1 Like

I think I have to continue learning (because I don’t understand that about construction helpers). But I’ve just started.

1 Like

Here’s some info about how the Blueprint Virtual Machine works…

between P_NATIVE_BEGIN and P_NATIVE_END is where usually a UFUNCTION makes the call to native C++ code.

If you do the bulk of your work within the native function, you can have blueprints just fine, they won’t affect much your runtime performance.

The macros within DEFINE_FUNCTION are the things to generate the nodes that you see on blueprint graphs.

2 Likes

Thanks! The article that you have shared is great! And its video too!

I have understood why they use BP classes that inherits from C++ classes, but I don’t think I need to create a BP class from each of my C++ class.

I think if I am extending the C++ class with Blueprints, because what I am extending it is better to do it in Blueprint, it makes sense to me.

But if I am only creating a Blueprint class that inherits from a C++ class because I do it mechanically, and I can use the C++ class in the level directly (without Blueprint), I won’t do it.

2 Likes

Hahahaa :joy:

i do a mix. I’m too lazy to put everything in English. I am from Spain

1 Like

At times you are forced to use parenting.

Take for instance characters and animations.

The animation class access in c++ is only really achievable by way of reparenting.
Because you have to keep an editor blueprint and add editor side stuff to it like state machines.

I’m suremaybe the same stuff can likely be entierly defined in c++, but good luck debugging state machines without a visual aid?

Another good reason to create c++ classes is to be able to do things natively. Like calling FMath::Dot instead of UKismetMathLibrary::Dot

The minimal benefit there is that its not one function calling another function and creating a stack of 2 functions before you get a result.
Ergo calling Fmath::Dot is supposedly faster.
The reality is it probably won’t matter at all and we all use the UKismet libraries anyway don’t we? :stuck_out_tongue_winking_eye:

MostHost_LA, sorry, but I haven’t understood anything you have said.

I can only speak specifically to my/my teams experience. We attempt to use C++ as base classes with extended BP classes for a few major reasons:

  • Performance: though a note is we do not do this to begin with. We build most things in BP and move them to C++ as we optimize. If something performs well on our target platforms in BP, we leave it in BP.
  • Easy collaboration: we are a team of mostly programmers with our artists largely being the designers as well. Most of the actual “logic” that will be in our final game will ultimately go through one of the programmers as our designers are typically working through a backlog of art resources needed. As programmers, we’re just more comfortable merging work with our existing workflows (source control). Any new features are knowingly thrown together in a very “prototype” BP approach by our designers to get the point across so they can then get back to working on art.
  • Easy iteration: while we’re most comfortable with the final game logic being in C++, we want to make sure we expose enough functionality via BP so our designers/artists can experiment and create new ideas.
  • Setup for support success: When crash data starts coming in from our players (it happens to all of us, there’s no escaping it), having the logic in a technology that enables us as a team to quickly triage/diagnose/resolve bugs is a major priority. For us, having our game designed so our programmers can largely solve most gameplay logic bugs independently and efficiently frees our artists up to continue working on new content for the game after launch.

All that being said, I’d summarize that it’s simply a matter of picking the tech that works best for you and your team.

As to why it’s always shown in things like training videos from a variety of sources, I can only speculate. If I had to, I’d guess it’s so they are able to say that they at least teach you the basics of working with the hybrid technology approach. At least you learn a tool that enables you to make an informed decision later in your development if you encounter any troubles that a hybrid tech approach would solve.

1 Like