Hello, I have just started learning C++ in Unreal Engine, I just have a question about C++ classes that are converted into Blueprint classes,
If I have a C++ class, SGrenade for example, and I handle all the logic of creating Projectile Movement and a Static Mesh Component in C++, along with logic that is to be played out once it is in flight/ fired.
However, if I expose some variables to be used for a Blueprint version of this Class, such as the ability to choose the static mesh of SGrenade (and Scale, Rotate, etc). Does the process of turning my C++ SGrenade class into a Blueprint Class that has its functionality written in C++ result in performance difference?
Eg. If this was a final release of a game, would it be better to have things such as the Static Mesh and Projectile Movement Components be set in C++ code, or would having BluePrinted version of these classes result in no tangible difference?
I will also like to add, that there is No visual scripting taking place, as I know this is slower than C++.
Well the whole point of using nativization is gaining performance but some folk saying that it may cause crashes and some unexpected behavior on some rare occasions. Never tested it thoroughly.
There is a test on youtube, nativization is gaining performance but nowhere near c++. You won’t lose much performance doing blueprint logic especially when its on construction (such as setting meshes and stuff), but any cpu intensive logic should be done in c++ for performance.
Nativization will only save you the cost of the Blueprint VM. It won’t make bad Blueprints any better, and it’s still far from optimal - especially when it comes to handling of containers etc.
There is no substitute for properly-written CPP code. The difference will be night and day.
So once I’ve created a Blueprint Class based upon a C++ Class, I can assume that the Blueprint is being used in the Blueprint VM, but the underlying logic that I’ve written in C++ is still being utilized and the performance of this logic would be near or the same as a native C++ class, or does the mere fact of it being created with the Blueprint mean that the C++ logic performance is hindered in some way?
Thanks again for any help, sorry if I misinterpreted anything, I’m quite new to this haha
What you’ve written in C++ is C++, whats in Blueprint is in Blueprint, there is no conversion or stuff, you’re just adding Blueprint logic on top of your C++.
Okay to clarify - it is the blueprint graph that costs.
If all you’re doing is creating a Blueprint asset of your native CPP class, and setting up some default values for properties etc, then there is zero overhead. Nativization won’t really achieve anything for assets like that, but it won’t do any harm either. This is also why there’s never a good reason to hardcode native CPP classes with asset references etc.
It’s calling functions and graph operations that create cost - because everything has to be called through reflection, and operations on containers (e.g, arrays and maps) are especially costly since they are nearly always treated as copies.
The best way to work in UE4 (with CPP) is to create native classes that have your common/complex behaviour, and let designers subclass those into Blueprints where they can script those behaviours and setup default property values.
It just helps to remember that Blueprint isn’t really a programming language, it’s a scripting language - albeit just a very powerful one.