I was following along a tutorial where I’m supposed to create some BP functions in C++. I did as the tutor showed and I got the c++ class - I just also got a c# class that I could edit as well! Is this something else, or can someone implement BP classes in C# now, using UE? I thought this engine is either BP or c++.
Thanks in advance.
The C# class that is created is used by the Unreal Header tool. You wouldn’t want to do anything with this class except add dependencys for modules you might want to use - for example, the AIModule, or the Slate UI module.
If you want to do coding you have to use C++, and I believe they also provide a lua binding as well.
Thank you for your reply.
What a pity, I’m more accustomed to c# myself - will have to get by in c++, or so it seems. Good thing I asked before messing up those files.
EDIT: moving this a new thread.
yeah! same here. Started using unreal a few months ago.
One tip that I messed up when I switched to C++:
Declare EVERYTHING that is a UCLASS, USTRUCT, or whatever as a UPROPERTY.
C# is a garbage collected language, so you don’t have to worry about memory management. C++ is not, and UPROPERTY’s are required so that unreal knows when to garbage collect your code.
When I first started, I didn’t have some of my core systems set as uproperty’s, and they would be randomly deallocated by the garbage collector. Not fun.
So yeah, use UPROPERTY and life will be awesome.
How to do this declaring as UPROPERTY? I used cpp before, but it was like a year ago and we freed up memory by hand - boy was it painful…
you do it in the header.
So, if you have a pointer to a class, say
AActor* someActor, in your .h file…
You would declare it as:
so that it automagically manages its own memory.
Just wanted to throw out a great starter tip:
C++ is the core engine of your game, Blueprints sit on top of that.
You can make C++ functions that are usable in Blueprints.
Blueprints make it VERY easy to create custom parts of your c++ actor.
For example, I have an Enemy.cpp class that has all the Enemy AI and such. I then make blueprints out of that class.
So I have a SkeletonWarrior blueprint, and SkeletonMage blueprint that use the Enemy.cpp class.
The cool part is that for the mage, I can make him glow when he attacks, and add these custom little features just for the mage all in Blueprints.
Since only the mage uses those extra things, no need to code them into the Enemy.cpp class, just add them in the Mage’s blueprint.
So by this you mean that basically ineritance works between cpp and blueprint? that’s awesome
I knew that one can create blueprint functions in cpp, however I’m only at the beginning of coding in UE. I used to make and fps game and a platformer in Unity, using c#. However, in unity you have this “now it works, now it doesn’t”, like schrödinger’s cat UE is more stable that’s for sure.